Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35273 > unrolled thread
| Started by | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| First post | 2016-08-12 15:56 +0200 |
| Last post | 2016-08-13 16:35 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
gc is freeing and claiming memory Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 15:56 +0200
Re: gc is freeing and claiming memory Florian Weimer <fw@deneb.enyo.de> - 2016-08-13 16:35 +0200
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2016-08-12 15:56 +0200 |
| Subject | gc is freeing and claiming memory |
| Message-ID | <87oa4yks54.fsf@Equus.decebal.nl> |
Because I saw certain applications took a lot of residential memory
and swap space I am looking a bit into memory management. I have the
following code:
long freeMemory = rt.freeMemory() / divideValue;
long totalMemory = rt.totalMemory() / divideValue;
logMessage(String.format("Maximum to use %d",
rt.maxMemory() / divideValue));
logMessage(String.format("Before %d - %d = %d",
totalMemory, freeMemory,
totalMemory - freeMemory));
System.gc();
freeMemory = rt.freeMemory() / divideValue;
totalMemory = rt.totalMemory() / divideValue;
logMessage(String.format("After %d - %d = %d",
totalMemory, freeMemory,
totalMemory - freeMemory));
One of the outputs is:
15:33:03: Maximum to use 228
15:33:03: Before 142 - 80 = 62
15:33:03: After 146 - 93 = 53
So while on the one hand there is 9 MB of memory freed, but at the
same time there is another 4 MB reserved. (I have seen a bigger
difference, there was on the one hand 4 MB freed and at the same time
32 MB extra reserved. But I did not save that.)
What is happening here?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [next] | [standalone]
| From | Florian Weimer <fw@deneb.enyo.de> |
|---|---|
| Date | 2016-08-13 16:35 +0200 |
| Message-ID | <8737m8spnb.fsf@mid.deneb.enyo.de> |
| In reply to | #35273 |
* Cecil Westerhof: > So while on the one hand there is 9 MB of memory freed, but at the > same time there is another 4 MB reserved. (I have seen a bigger > difference, there was on the one hand 4 MB freed and at the same time > 32 MB extra reserved. But I did not save that.) > > What is happening here? Maybe something related to GC ergonomics. The JVM might try to resize the heap to avoid too frequent collections. For details, you need to switch on GC debugging messages and look at GC statistics instead overall system statistics.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web