🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Memory

#8293
From: Valentino Kyriakides
Date: Wed, 28 Mar 2001 18:51
59 lines
3136 bytes
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: <3ac230e7$1_2@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!195.180.208.145
References: <3AC1CFA5.E12BF796@tryllian.com>

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-28 10:58:22 PST
From: "Valentino Kyriakides" <vkyr@ision.net>
Newsgroups: borland.public.jbuilder.java.language
References: <3AC1CFA5.E12BF796@tryllian.com>
Subject: Re: Memory
Date: Wed, 28 Mar 2001 20:51:39 +0200
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
NNTP-Posting-Host: 195.180.208.145
Message-ID: <3ac230e7$1_2@dnews>
X-Trace: 28 Mar 2001 10:43:51 -0800, 195.180.208.145
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!hermes2.visi.com!news-out.visi.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews!195.180.208.145