Search:     Advanced search
server monitoring

Code Correctness: Call to System.gc()

Article ID: 55
Last updated: 06 May, 2008
Views: 317
Posted: 06 May, 2008
by: Tech Pubs S.
Updated: 06 May, 2008
by: Tech Pubs S.

Code Correctness: Call to System.gc()

Abstract

Explicit requests for garbage collection are a bellwether indicating likely performance problems.

Description

At some point in every Java developer's career, a problem surfaces that appears to be so mysterious, impenetrable, and impervious to debugging that there seems to be no alternative but to blame the garbage collector. Especially when the bug is related to time and state, there may be a hint of empirical evidence to support this theory: inserting a call to System.gc() sometimes seems to make the problem go away.

In almost every case we have seen, calling System.gc() is the wrong thing to do. In fact, calling System.gc() can cause performance problems if it is invoked too often.


This article was:   Helpful | Not Helpful
Prev   Next
Vulnerability     J2EE Bad Practices: Sockets