Tenured Memory question
843829Dec 13 2007 — edited Dec 14 2007Hello,
I have an application that I am trying to figure out why is taking up so much memory. When I load up the program it runs at around 70 MB. I do FUNCTION A, and it increases to 120 MB (In Windows Task Manager). I thought I was getting a memory leak, so I ran a profiler on my program and looked at the heap allocation. This is what I have determined:
1.) The number of objects from 70 MB to 120 MB does not change. What I mean is: Let's say at 70 MB I have a list of 16,000 integers. I perform FUNCTION A, which involves clearing the integer list and inserting 16,000 new integers in it. Before FUNCTION A, I have 16,000 integers. After FUNCTION A, I still have 16,000 integers.
2.) Seeing as I do not have a memory leak with the items in the list (ie: 32,000 integers), I then looked at the detailed memory allocation a bit more in detail. Right before I perform FUNCTION A, my Tenured Generation is around 8 MB. After I run FUNCTION A, my Tenured Generation leaps to 50 MB! I run the GC (My profiler has an option to do so), my Tenured Generation does not lower.
So it seems that I have a bunch of unwanted memory in the Tenured Generation section and I would like to get rid of it. It is taking up space in my program.
I read some documentation on the memory management and it seems that, only a Full GC will clear out the tenured generation. But, even during a long run time, say 5 minutes, it still doesn't clean out the memory. I turned verbose on for the GC, and it didn't seem to do a full collect during that time period. If I keep doing FUNCTION A over and over again, the size of the memory does not increase, however, the Tenured Collection seems to not getting cleared out.
To give some statistics from the printouts:
I do FUNCTION A the first time: The GC says it went from 95MB->83MB.
Windows Task Manager has my program at 123 MB.
I do FUNCTION A again: The GC says it now cleans at 60MB->52MB.
Windows Task Manager still has my program at 123 MB.
So I guess my question is two fold:
How do I set the GC to do more cleaning on the Tenured Generation, or lower the amount of memory that can go in there before it gets cleaned out? I'm running at 128 for the heap.
Why does Windows Task report the wrong data OR how do I have the GC printout all of the memory generations (I believe this is what is occurring and I only have a portion of the information)?
Thanks!
PS: I am new at Java memory management so bare with me :)
PSS: I just saw the GC do a full collection and it went down to like 50 MB, but Windows Task Manager still is reporting +100 MB. I am confused!
PSSS: I know 16,000 integers != the memory increase, I am just using that as a simple example.
Edited by: dayrinni on Dec 13, 2007 11:45 AM
Edited by: dayrinni on Dec 13, 2007 1:06 PM