🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8295

Re: Memory

#8295
From: Ronald Wildenberg
Date: Thu, 29 Mar 2001 08:23
78 lines
4003 bytes
Hi,

Thanks for the answer. I did not know the default initial heap
size was 2MB. I can not run my program from within JB so I
can not use your Memory Monitor (I guess).

I print the totalMemory() and freeMemory() every minute and
totalMemory() *does* grow. It seems to me that totalMemory() returns
not the total amount of available memory (as I would have expected)
but the total amount of memory currently reserved for new objects.
This amount can grow to the maximum specified size of 160MB.

I do not find the JavaDoc comment on totalMemory() clear on this.
To me it looks as if the method should return the maximum heap
size, which it does not.

Ronald.

Valentino Kyriakides wrote:

> Ronald Wildenberg <ronald@tryllian.com> schrieb in im Newsbeitrag:
> 3AC1CFA5.E12BF796@tryllian.com...
> > Hi,
> >
> > I have a program which uses quite a lot of memory so
> > I can not use the default maximum heap size.
> > Instead, I supply the parameter '-Xmx160m' to java,
> > giving the VM a maximum heap size of 160MB.
> >
>
> Looks good so far, AFAIK it is the right option to specify the maximum size,
> in bytes, of the memory allocation pool.
>
> > Now, when I use 'Runtime.getRuntime().totalMemory()'
> > it returns 2031616. This is not what I expect for it is
> > approximately 2MB.
>
> Hmm, this looks like the default initial size, in bytes, of the memory
> allocation pool, which is 2MB.
>
> > My question is: Have I supplied the wrong parameter
> > to the JVM or do I not understand the method
> > totalMemory()?
>
> IMO your understanding of the totalMemory() method is Ok so far. The JDK
> help says about "totalMemory()":
>
> -----------------------------------
> totalMemory
>
>    public long totalMemory()
>
> Returns the total amount of memory in the Java Virtual Machine. The value
> returned by this method may vary over time, depending on the host
> environment. Note that the amount of memory required to hold an object of
> any given type may be implementation-dependent.
>
> Returns: the total amount of memory currently available for current and
> future objects, measured in bytes.
> -----------------------------------
>
> I think that the memory allocation pool will dynamically grow. Did you
> proved this with your program?  If you are able to run your program from
> inside of JB via it's VM, you can take my JB Memory Monitor from
> CodeCentral, see:
>
> http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=15755
>
> So you can easily inspect the heap memory consumption of the whole JB IDE.
> Otherwise, you will have to do multiple "long totalBytes =
> Runtime.getRuntime().totalMemory();" calls at different states during the
> execution of your program (at the start, middle and end...etc.) in order to
> get some usefull results for comparison. You may also do some "long
> freeBytes = Runtime.getRuntime().freeMemory();" calls, so you can determine
> if the free heap memory shrinks at all etc. and how much mem is released
> after a possibly GC.
>
> Valentino
Technical Details
Message-ID: <3AC2F0F9.4D868EFB@tryllian.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!209.50.235.254!europa.netcrusader.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!62.58.162.210
References: <3AC1CFA5.E12BF796@tryllian.com> <3ac230e7$1_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9849fe78e24e781
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-29 00:37:54 PST
Message-ID: <3AC2F0F9.4D868EFB@tryllian.com>
Date: Thu, 29 Mar 2001 10:23:21 +0200
From: Ronald Wildenberg <ronald@tryllian.com>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Memory
References: <3AC1CFA5.E12BF796@tryllian.com> <3ac230e7$1_2@dnews>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 62.58.162.210
X-Trace: 29 Mar 2001 00:21:30 -0800, 62.58.162.210
Lines: 79
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!209.50.235.254!europa.netcrusader.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews!62.58.162.210