Re: possible memory leak?? - Mailing list pgsql-jdbc

From Jens Carlberg
Subject Re: possible memory leak??
Date
Msg-id 3DCBF93A.4040506@lysator.liu.se
Whole thread Raw
In response to DatabaseMetaData.getTables problem  (snpe <snpe@snpe.co.yu>)
List pgsql-jdbc
Michael Paesold wrote:
> Dave Cramer <Dave@micro-automation.net> wrote:
>
>
>>Should the gc run before an OutOfMemoryException is thrown
>>
>>in other words are the jvm's smart enough to run the gc if they are out
>>of memory?
>
>
> Yes, the jvm should be smart enough to regain unused memory before throwing
> an OutOfMemoryException. The global gc runs in the backround in defined
> intervals, but more often in low memory situations, as far as I know.

 From the documentation of the OutOfMemoryError:

"Thrown when the Java Virtual Machine cannot allocate an object because
it is out of memory, and no more memory could be made available by the
garbage collector. "

Thus, the VM tries to get the memory needed through a garbage collection
before it gives up and throws an error.

<snip>
> Does the overall memory consumption increase, even with System.gc() called
> explicitly? Have you tried running it until the jvm needs more than maximum
> allowed memory? (the limit can be set with command line arguments)

Also, add the flag -verbose:gc to java to see the actual garbage
collection taking place. If you combine that with adding a System.gc()
you'll probably end up with enough debug info.

--
       _/ _/_/_/ _/   _/ _/_/_/ | Jens Carlberg
      _/ _/     _/_/ _/  _/     | jenca@lysator.liu.se
     _/ _/_/   _/ _/_/    _/    | +46 13 260872
_/_/  _/_/_/ _/   _/ _/_/_/    | ICQ: 44194995


pgsql-jdbc by date:

Previous
From: Michael Stephenson
Date:
Subject: Retrieving foreign key information via jdbc
Next
From: Barry Lind
Date:
Subject: Re: DatabaseMetaData.getTables problem