Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35176

Re: Memory usage

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Memory usage
Date 2016-08-02 17:28 -0400
Organization A noiseless patient Spider
Message-ID <nnr3ac$oun$1@dont-email.me> (permalink)
References <878twegamc.fsf@Equus.decebal.nl>

Show all headers | View raw


On 8/2/2016 4:48 PM, Cecil Westerhof wrote:
> 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?

     Maybe some large objects were allocated?  Even when using only
512K of 4M, `new int[1000][1000]' might well prompt a GC.

     Keep in mind that the state of the art (and "art" it is!) in
garbage collection is constantly in flux.  When I was at Sun, they
were forever tinkering with different garbage collectors and tunings
and auto-adjustments and heuristics and whatnot, and I have no reason
to think the work ceased when Sun set.  That is, Oracle is very likely
still changing GC stuff from release to release and even from patch to
patch -- meaning that both the command-line controls (recall that "The
-X options are non-standard and subject to change without notice") and
the output of the GC traces may not mean the same thing today that
they did six months ago ...

     You don't mention what Java release you're using, but if it's SE8
you might find something useful at

http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html

     Good luck!

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Memory usage Cecil Westerhof <Cecil@decebal.nl> - 2016-08-02 22:48 +0200
  Re: Memory usage Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-02 17:28 -0400
  Re: Memory usage Arne Vajhøj <arne@vajhoej.dk> - 2016-08-02 17:49 -0400
    Re: Memory usage Arne Vajhøj <arne@vajhoej.dk> - 2016-08-02 17:52 -0400
  Re: Memory usage Roedy Green <inquiry@mindprod.com> - 2016-08-02 17:51 -0700
  Re: Memory usage Nigel Wade <nmw@local.domain> - 2016-08-03 13:11 +0100

csiph-web