Suppose I have a Swings Java Application,
I set the min Heap is 64MB and max Heap 2GB,
when the user start the application, the log in screen
will be displayed, at this time the app uses 64MB, rights?
From my Windows 7, I can see the java application is allocated 64MB
from the Memory Resource Monitor of the OS (actually, it's more than 64MB because JVM need some memory for it's task).
After that the user does some very heavy job then the application uses 2G.
Then the user log out the application, the log in screen is displayed again (the application is not closed yet). At this time the real memory that the application
is using 64MB (suppose this is the perfect memory management application),
but with the OS this application is still using 2G of RAM, I can see it on the resource monitor of the OS.
I want my application release the memory to the OS when it doesn't need to use a big memory. Can I do it at runtime with java app?
I mean when my application need to use 64MB of Ram,
then the OS gives it 64MB only,
when it need 2GB of ram then the OS gives it 2GB,
after that it need 64MB of ram then the OS gives it 64MB only again,
I don't want it waste 2000MB - 64MB = 1936MB.
Can I do that?
Thanks,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…