Skip to main content

Re: [JAVA2D] memory limit problems with Java and System.gc()

5 replies [Last post]
Anonymous

Dear David,

thank you for the advice concerning memory mapped files. Though this are interesting topics, the ideas do not solve my problem. The memory leaks occur due to extensive formation of strings, arrays of strings and other objects, but not from file accession.

The problem is to free the memory occupied by objects that are no longer needed; obviously, the invocation of System.gc() does not really help.

Perhaps this problem is hard to solve in Java? I need a mechanism that is similar to the concept of a C++ destructor or something like Graphics.dispose() but suited for instances of any class. Doesnt there exist something stronger then just to rely on the garbage collection?

Another thing that would help is to overcome the daunting 1GB RAM limit for java when calling the virtual machine with the Xmx attribute. Is there a trick to make the whole 2GB RAM available to Java?

Sorry for repeated questioning,
Sven

"Rosenstrauch, David" schrieb am 20.07.04 15:31:58:
>
>
>
> > -----Original Message-----
> > From: Sven Mielordt [mailto:mielordt@web.de]
> > Sent: Tuesday, July 20, 2004 9:14 AM
> > To: Rosenstrauch, David
> > Subject: Re: [JAVA2D] memory problems with Java and System.gc()
> >
> >
> > That sounds nice, how can I use them and what Java version is needed?
>
>
> As of JDK1.4, it looks like.
>
> Start with these:
>
> http://www.developer.com/java/other/article.php/1548681
> http://javaalmanac.com/egs/java.nio/CreateMemMap.html?l=rel
>
> I'm sure you can google up some other references from there.
>
> DR
>
> ==============================================================================
> This message is for the sole use of the intended recipient. If you received
> this message in error please delete it and notify us. If this message was
> misdirected, CSFB does not waive any confidentiality or privilege. CSFB
> retains and monitors electronic communications sent through its network.
> Instructions transmitted over this system are not binding on CSFB until they
> are confirmed by us. Message transmission is not guaranteed to be secure.
> ==============================================================================
>

_______________________________________________________
WEB.DE Video-Mail - Sagen Sie mehr mit bewegten Bildern
Informationen unter: http://freemail.web.de/?mc=021199

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mthornton
Offline
Joined: 2003-06-10

Why do you think the heap limit is only 1GB?

See bug 4358809 for some information on the heap limit in Windows.

Dmitri Trembovetski

On Tue, Jul 20, 2004 at 04:48:40PM +0200, Sven Mielordt wrote:
> Dear David,
>
> thank you for the advice concerning memory mapped files. Though this are interesting topics, the ideas do not solve my problem. The memory leaks occur due to extensive formation of strings, arrays of strings and other objects, but not from file accession.
>
> The problem is to free the memory occupied by objects that are no longer needed; obviously, the invocation of System.gc() does not really help.
>
> Perhaps this problem is hard to solve in Java? I need a mechanism that is similar to the concept of a C++ destructor or something like Graphics.dispose() but suited for instances of any class. Doesnt there exist something stronger then just to rely on the garbage collection?
>
> Another thing that would help is to overcome the daunting 1GB RAM limit for java when calling the virtual machine with the Xmx attribute. Is there a trick to make the whole 2GB RAM available to Java?
>

Have you tried using server vm?

Dmitri

> Sorry for repeated questioning,
> Sven
>
>
> "Rosenstrauch, David" schrieb am 20.07.04 15:31:58:
> >
> >
> >
> > > -----Original Message-----
> > > From: Sven Mielordt [mailto:mielordt@web.de]
> > > Sent: Tuesday, July 20, 2004 9:14 AM
> > > To: Rosenstrauch, David
> > > Subject: Re: [JAVA2D] memory problems with Java and System.gc()
> > >
> > >
> > > That sounds nice, how can I use them and what Java version is needed?
> >
> >
> > As of JDK1.4, it looks like.
> >
> > Start with these:
> >
> > http://www.developer.com/java/other/article.php/1548681
> > http://javaalmanac.com/egs/java.nio/CreateMemMap.html?l=rel
> >
> > I'm sure you can google up some other references from there.
> >
> > DR
> >
> > ==============================================================================
> > This message is for the sole use of the intended recipient. If you received
> > this message in error please delete it and notify us. If this message was
> > misdirected, CSFB does not waive any confidentiality or privilege. CSFB
> > retains and monitors electronic communications sent through its network.
> > Instructions transmitted over this system are not binding on CSFB until they
> > are confirmed by us. Message transmission is not guaranteed to be secure.
> > ==============================================================================
> >
>
>
> _______________________________________________________
> WEB.DE Video-Mail - Sagen Sie mehr mit bewegten Bildern
> Informationen unter: http://freemail.web.de/?mc=021199
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Dmitri Trembovetski

On Wed, Jul 21, 2004 at 05:10:25AM -0700, Dmitri Trembovetski wrote:
> On Tue, Jul 20, 2004 at 04:48:40PM +0200, Sven Mielordt wrote:
> > Dear David,
> >
> > thank you for the advice concerning memory mapped files. Though this are interesting topics, the ideas do not solve my problem. The memory leaks occur due to extensive formation of strings, arrays of strings and other objects, but not from file accession.
> >
> > The problem is to free the memory occupied by objects that are no longer needed; obviously, the invocation of System.gc() does not really help.
> >
> > Perhaps this problem is hard to solve in Java? I need a mechanism that is similar to the concept of a C++ destructor or something like Graphics.dispose() but suited for instances of any class. Doesnt there exist something stronger then just to rely on the garbage collection?
> >
> > Another thing that would help is to overcome the daunting 1GB RAM limit for java when calling the virtual machine with the Xmx attribute. Is there a trick to make the whole 2GB RAM available to Java?
> >
>
> Have you tried using server vm?

Also, my understanding is that on x86 an application (or the OS, for that matter),
can't get access to the whole 2G of theoretically addressable space.
You'll either need some special hardware which will do some
trickery, or a truly 64-bit system and OS.

Thank you,
Dmitri

>
> Dmitri
>
> > Sorry for repeated questioning,
> > Sven
> >
> >
> > "Rosenstrauch, David" schrieb am 20.07.04 15:31:58:
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Sven Mielordt [mailto:mielordt@web.de]
> > > > Sent: Tuesday, July 20, 2004 9:14 AM
> > > > To: Rosenstrauch, David
> > > > Subject: Re: [JAVA2D] memory problems with Java and System.gc()
> > > >
> > > >
> > > > That sounds nice, how can I use them and what Java version is needed?
> > >
> > >
> > > As of JDK1.4, it looks like.
> > >
> > > Start with these:
> > >
> > > http://www.developer.com/java/other/article.php/1548681
> > > http://javaalmanac.com/egs/java.nio/CreateMemMap.html?l=rel
> > >
> > > I'm sure you can google up some other references from there.
> > >
> > > DR
> > >
> > > ==============================================================================
> > > This message is for the sole use of the intended recipient. If you received
> > > this message in error please delete it and notify us. If this message was
> > > misdirected, CSFB does not waive any confidentiality or privilege. CSFB
> > > retains and monitors electronic communications sent through its network.
> > > Instructions transmitted over this system are not binding on CSFB until they
> > > are confirmed by us. Message transmission is not guaranteed to be secure.
> > > ==============================================================================
> > >
> >
> >
> > _______________________________________________________
> > WEB.DE Video-Mail - Sagen Sie mehr mit bewegten Bildern
> > Informationen unter: http://freemail.web.de/?mc=021199
> >
> > ===========================================================================
> > To unsubscribe, send email to listserv@java.sun.com and include in the body
> > of the message "signoff JAVA2D-INTEREST". For general help, send email to
> > listserv@java.sun.com and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

David Kavanagh

I've done apps that use Java2D and cycle through large amounts of memory. We
even had one running on a large Sun server with 2G allocated to it and it was
stable over the long run. That was with 1.3.1, and things have improved with
1.4.x. I recommend reading some of the documentation found here;
http://java.sun.com/docs/hotspot/index.html
In general, if you configure the JVM correctly, you shouldn't need to call
System.gc() ever.
If you still have problems, try something like JProbe or OptiimizeIt to fine the
source of your memory problems. If you have references to these strings, those
tools can find them!

Best of luck,
David

Quoting Sven Mielordt :

> Dear David,
>
> thank you for the advice concerning memory mapped files. Though this are
> interesting topics, the ideas do not solve my problem. The memory leaks occur
> due to extensive formation of strings, arrays of strings and other objects,
> but not from file accession.
>
> The problem is to free the memory occupied by objects that are no longer
> needed; obviously, the invocation of System.gc() does not really help.
>
> Perhaps this problem is hard to solve in Java? I need a mechanism that is
> similar to the concept of a C++ destructor or something like
> Graphics.dispose() but suited for instances of any class. Doesnt there exist
> something stronger then just to rely on the garbage collection?
>
> Another thing that would help is to overcome the daunting 1GB RAM limit for
> java when calling the virtual machine with the Xmx attribute. Is there a
> trick to make the whole 2GB RAM available to Java?
>
> Sorry for repeated questioning,
> Sven
>
>
> "Rosenstrauch, David" schrieb am 20.07.04
> 15:31:58:
> >
> >
> >
> > > -----Original Message-----
> > > From: Sven Mielordt [mailto:mielordt@web.de]
> > > Sent: Tuesday, July 20, 2004 9:14 AM
> > > To: Rosenstrauch, David
> > > Subject: Re: [JAVA2D] memory problems with Java and System.gc()
> > >
> > >
> > > That sounds nice, how can I use them and what Java version is needed?
> >
> >
> > As of JDK1.4, it looks like.
> >
> > Start with these:
> >
> > http://www.developer.com/java/other/article.php/1548681
> > http://javaalmanac.com/egs/java.nio/CreateMemMap.html?l=rel
> >
> > I'm sure you can google up some other references from there.
> >
> > DR
> >
> >
>
==============================================================================
> > This message is for the sole use of the intended recipient. If you
> received
> > this message in error please delete it and notify us. If this message was
> > misdirected, CSFB does not waive any confidentiality or privilege. CSFB
> > retains and monitors electronic communications sent through its network.
> > Instructions transmitted over this system are not binding on CSFB until
> they
> > are confirmed by us. Message transmission is not guaranteed to be secure.
> >
>
==============================================================================
> >
>
>
> _______________________________________________________
> WEB.DE Video-Mail - Sagen Sie mehr mit bewegten Bildern
> Informationen unter: http://freemail.web.de/?mc=021199
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> Questions, Problems or Concerns contact messagelabs-admin@dotech.com.
> ______________________________________________________________________
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

mthornton
Offline
Joined: 2003-06-10

> In general, if you configure the JVM correctly, you
> shouldn't need to call
> System.gc() ever.

Unfortunately there are a few exceptions, notably when using memory mapping. The problem here is that old unreachable mappings gobble up address space and the gc is not automatically invoked when a new mapping fails due to the lack of address space.
RMI also invokes gc regularly because even though there may not be a local resource constraint, unreachable objects are keeping remote objects alive on machines that may be resource constrained.