Login  Register

Re: Memory leak

Posted by Michael Bien on Oct 21, 2011; 5:23pm
URL: https://forum.jogamp.org/Memory-leak-tp3441326p3441429.html


On 10/21/2011 06:51 PM, Tomd [via jogamp] wrote:
> This isn't technically a memory leak, because the buffers are always
> freed eventually. But I fear that if someone created a number of
> images the allocations might use up all memory before the GC kicked in.
  you don't have to fear this scenario since the GC *will* kick in as
soon the heap is full. All throughput collectors are very lazy in
cleaning up. Why should they release resources if they don't have to?
(possible GC triggers for the old generation are: heap fragmentation,
concurrent cleanup thresholds or out of memory)

so actually to find out the actual mem consumption of your application
you can check out the used heap value right after a full GC (you can
trigger this with visualvm or other tools).

large objects like large byte arrays are often allocated directly in the
old generation of the heap, thats why they survive longer as the small
ones. Direct NIO buffers get special treatment (this is about to change
in future JVM updates) and are allocated in a even more lazy area (next
to stuff like the class files). So consider using direct nio buffers as
static allocated memory instead of allocating them in inner loops.

regards,
michael