Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Memory usage Date: Tue, 02 Aug 2016 22:48:59 +0200 Organization: Decebal Computing Lines: 34 Message-ID: <878twegamc.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="12baf5125b19322b899c79c2e3878015"; logging-data="19451"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sYbHuwM10HhYkn2sbt9a3xhRYAeU6Kv8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:3OryrlM4Sac1jLdWhB8dQX6GIUQ= sha1:hqSgFJ+duzp/dmOxpOZlDRnTvNA= Xref: csiph.com comp.lang.java.programmer:35175 I have a Java application which I start with the parameters: -Xms4M -Xmx8M So the initial heap size will be 4 MB and the maximum will be 8 MB. But some strange things happen. Almost immediately the GC is running: 2016-07-09T10:14:34.537+0200: 0.257: [GC (Allocation Failure) 512K->488K(3584K), 0.0029586 secs] 2016-07-09T10:14:34.771+0200: 0.491: [GC (Allocation Failure) 1000K->496K(3584K), 0.0012720 secs] 2016-07-09T10:14:34.815+0200: 0.535: [GC (Allocation Failure) 1008K->552K(3584K), 0.0014619 secs] 2016-07-09T10:14:35.496+0200: 1.216: [GC (Allocation Failure) 1064K->656K(4096K), 0.0017656 secs] 2016-07-09T10:14:36.035+0200: 1.755: [GC (Allocation Failure) 1680K->1048K(4096K), 0.0023148 secs] But why? Minimum size is 4 MB, so why does it run when there is only half an MB allocated? At the moment I see: 2016-08-02T07:18:14.364+0200: 2062960.388: [GC (Allocation Failure) 4576K->3192K(5632K), 0.1543506 secs] 2016-08-02T09:23:04.833+0200: 2070450.857: [GC (Allocation Failure) 4728K->3168K(5632K), 0.0010015 secs] 2016-08-02T16:18:20.051+0200: 2095366.075: [GC (Allocation Failure) 4704K->3112K(5632K), 0.0017111 secs] 2016-08-02T19:37:35.176+0200: 2107321.200: [GC (Allocation Failure) 4648K->3056K(5632K), 0.0014402 secs] So the heap is still around 4 MB. But when I look at memory used and swap used (it is on an openSUSE 13.2 system) then I see that used memory is 37 MB and used swap is 57 MB. How is it possible that these are so high? When I close the program and start it again, it only uses 40 MB memory. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof