Strange behavior of memory when i make profiling

2019-07-22 03:56发布

问题:

I have a strange problem when i make profiling. I explain, in figure belows, we can see clairly that the greatest object take only 35mo. see this figure : . But when i verify a memory used at the same time i remark that it exceed 500mo

Some one can explain me why the greatest object take maximum 35mo while the heap used exceed 500 for the same time ? and how calculate heap used ?

回答1:

Probably you are not profiling all object creations. One of the standard profiling settings in Netbeans profiles only 1 in 10 object creations. Your measurement sais 35MB is 51% of your data. So you have profiled 70MB in total. This is roughly 1/10 of what you are measuring as the total heap size.

In general measuring only part of the creations is enough if you are looking for clues to who is the big memory spender. The reason for not tracking all creations is performance.

If you want to see where all your memory is used you can do the following:

In Netbeans 6.9.1 this is a setting saying 'Track every ... object allocations'. You can lower this number (if 1 in 10 doesn't help you find your problem, nor tells you enough about the application). It is possible however that this makes it impossible for your application to be run.

You can also make a heap dump. This will not contain information about creation and removal of objects, but it will tell you all objects currently in alive in your application.