Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to prevent out of memory errors?
How to prevent out of memory errors? [message #239138] Thu, 21 December 2006 13:11 Go to next message
Eclipse UserFriend
Originally posted by: james_adams.yahoo.com

I often need to restart Eclipse due to an out of memory error. I am
running on a Windows XP system with 3Gb of RAM, and the memory usage of
Eclipse's javaw process never exceeds 500Mb (reported by the Task
Manager). Perhaps I am using the wrong JVM options when I start Eclipse?
I currently use "-Xms256m -Xmx1024m", but I have tweaked these values
several times with no apparent effect. I have noticed over the years that
Ant builds and JUnit tests result in memory leaks when you launch them in
Eclipse -- is there something I can do which might minimize this and hence
reduce the number of out of memory errors I experience?

My configuration info:

Eclipse SDK
Version: 3.2.1
Build id: M20060921-0945

J2EE Standard Tools
Version: 1.5.2.v200610070620-kW-OA1vfaZTJtXg
Build id: 200606281211

Web Standard Tools
Version: 1.5.2.v200610070620-X3Tmm8_VLz2EcCH
Build id: 200606281211

Subclipse
Version: 1.1.9


Thanks in advance for any suggestions.


--James
Re: How to prevent out of memory errors? [message #239148 is a reply to message #239138] Thu, 21 December 2006 16:15 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------010309020405000109080406
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

If it is out of perm space error, you should also set the memories for it.

Drop the attached ini file to your eclipse root and see if it works

Hasan Ceylan
James Adams wrote:
> I often need to restart Eclipse due to an out of memory error. I am
> running on a Windows XP system with 3Gb of RAM, and the memory usage of
> Eclipse's javaw process never exceeds 500Mb (reported by the Task
> Manager). Perhaps I am using the wrong JVM options when I start
> Eclipse? I currently use "-Xms256m -Xmx1024m", but I have tweaked these
> values several times with no apparent effect. I have noticed over the
> years that Ant builds and JUnit tests result in memory leaks when you
> launch them in Eclipse -- is there something I can do which might
> minimize this and hence reduce the number of out of memory errors I
> experience?
>
> My configuration info:
>
> Eclipse SDK
> Version: 3.2.1
> Build id: M20060921-0945
>
> J2EE Standard Tools
> Version: 1.5.2.v200610070620-kW-OA1vfaZTJtXg
> Build id: 200606281211
>
> Web Standard Tools
> Version: 1.5.2.v200610070620-X3Tmm8_VLz2EcCH
> Build id: 200606281211
>
> Subclipse
> Version: 1.1.9
>
>
> Thanks in advance for any suggestions.
>
>
> --James
>


--------------010309020405000109080406
Content-Type: text/plain;
name="eclipse.ini"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="eclipse.ini"

-vmargs
-Xms40m
-Xmx512m
-XX:PermSize=64M
-XX:MaxPermSize=128M
--------------010309020405000109080406--
Re: How to prevent out of memory errors? [message #239158 is a reply to message #239148] Fri, 22 December 2006 05:41 Go to previous messageGo to next message
Eclipse UserFriend
Hasan Ceylan wrote:
> If it is out of perm space error, you should also set the memories for it.
>
> Drop the attached ini file to your eclipse root and see if it works
>
> Hasan Ceylan
> James Adams wrote:
>> I often need to restart Eclipse due to an out of memory error. I am
>> running on a Windows XP system with 3Gb of RAM, and the memory usage
>> of Eclipse's javaw process never exceeds 500Mb (reported by the Task
>> Manager). Perhaps I am using the wrong JVM options when I start
>> Eclipse? I currently use "-Xms256m -Xmx1024m", but I have tweaked
>> these values several times with no apparent effect. I have noticed
>> over the years that Ant builds and JUnit tests result in memory leaks
>> when you launch them in Eclipse -- is there something I can do which
>> might minimize this and hence reduce the number of out of memory
>> errors I experience?
>>
>> My configuration info:
>>
>> Eclipse SDK
>> Version: 3.2.1
>> Build id: M20060921-0945
>>
>> J2EE Standard Tools
>> Version: 1.5.2.v200610070620-kW-OA1vfaZTJtXg
>> Build id: 200606281211
>>
>> Web Standard Tools
>> Version: 1.5.2.v200610070620-X3Tmm8_VLz2EcCH
>> Build id: 200606281211
>>
>> Subclipse
>> Version: 1.1.9
>>
>>
>> Thanks in advance for any suggestions.
>>
>>
>> --James
>>
>
>
> ------------------------------------------------------------ ------------
>
> -vmargs
> -Xms40m
> -Xmx512m
> -XX:PermSize=64M
> -XX:MaxPermSize=128M

You can also pass these parameters as command-line options via the
eclipse shortcut.
Re: How to prevent out of memory errors? [message #239177 is a reply to message #239148] Sun, 24 December 2006 21:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: james_adams.yahoo.com

Unfortunately this isn't really helping, no matter how I monkey with the
heap or permanent generation memory values. I was using the values below
in my eclipse.ini the last time it crashed (OutOfMemoryError: PermGen
space):

-vmargs
-Xms120m
-Xmx1024m
-XX:PermSize=256M
-XX:MaxPermSize=512M

I recently added another 2Gb of RAM to my system in order to avoid just
this sort of problem. I thought I could just pop it in and not have to
update any of my Windows XP system configuration settings. Was this
perhaps just wishful thinking, i.e. is it possible that this is a problem
outside of the realm of Eclipse which might require for me to make some
system configuration changes for my extra memory? Bear in mind that
Eclipse is the only program I run on this system which crashes because it
runs out of memory, and it happens when there is a full 1Gb or more of
memory to spare. Fortunately when this sort of crash happens Eclipse
doesn't corrupt or lose much data other than its UI state, but this
periodic crashing (once every two hours or so) is an annoyance I'd like to
avoid if possible, especially since I just spent $250 for additional
memory which I thought would prevent this sort of thing from happening.

Any further ideas would be greatly appreciated.


--James
Re: How to prevent out of memory errors? [message #239204 is a reply to message #239177] Sun, 24 December 2006 23:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

James Adams wrote:
> Unfortunately this isn't really helping, no matter how I monkey with the
> heap or permanent generation memory values. I was using the values
> below in my eclipse.ini the last time it crashed (OutOfMemoryError:
> PermGen space):
>
> -vmargs
> -Xms120m
> -Xmx1024m
> -XX:PermSize=256M
> -XX:MaxPermSize=512M
>
> I recently added another 2Gb of RAM to my system in order to avoid just
> this sort of problem. I thought I could just pop it in and not have to
> update any of my Windows XP system configuration settings. Was this
> perhaps just wishful thinking, i.e. is it possible that this is a
> problem outside of the realm of Eclipse which might require for me to
> make some system configuration changes for my extra memory? Bear in
> mind that Eclipse is the only program I run on this system which crashes
> because it runs out of memory, and it happens when there is a full 1Gb
> or more of memory to spare. Fortunately when this sort of crash happens
> Eclipse doesn't corrupt or lose much data other than its UI state, but
> this periodic crashing (once every two hours or so) is an annoyance I'd
> like to avoid if possible, especially since I just spent $250 for
> additional memory which I thought would prevent this sort of thing from
> happening.
> Any further ideas would be greatly appreciated.

The best lesson I guess you can learn from it is that physical RAM
capacity is far different than what the JVM can get or will use :-) Just
adding RAM is not enough to give Java more - you must tweak the settings
of the JVM, as you are trying to do with eclipse.ini - besides that, a
gig of RAM on windoze XP should be more than enough, even with lots of
other stuff running (for example, I run Firefox, Thunderbird, MySQL, and
Eclipse pretty much 24/7 and hardly ever see my system memory usage go
much above 1GB).
It is not clear to me what the problem is, since your VM options seem to
be valid (in fact, 512MB is about 3-4 times more memory than PermGen
space should ever need - I run Eclipse + WTP with only 128 max perm gen
space.
Only thing I would suggest is specifying a specific vm in the ini file,
to make sure Eclipse is using the JVM version you think it is. Also,
have you tried posting the .log file from a time when you see the OOM error?

Hope this helps,
Eric
Re: How to prevent out of memory errors? [message #239209 is a reply to message #239177] Mon, 25 December 2006 03:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thunderaxiom.gmail.com

James Adams skrev den 25-12-2006 03:09:

> mind that Eclipse is the only program I run on this system which crashes
> because it runs out of memory, and it happens when there is a full 1Gb
> or more of memory to spare. Fortunately when this sort of crash happens

It is not because your JVM cannot get any more memory from your
operating system, but because some internal data structure to the JVM
runs full.

I have never seen this message so I was wondering if perhaps it is your
basic Java installation or work pattern that is different from mine.

What does "java -version" and "java -fullversion" report on your system?
Could you elaborate on what you actually DO with Eclipse?

Could you try the new Java 1.6 from Sun?

--
Thorbjørn
Re: How to prevent out of memory errors? [message #239241 is a reply to message #239209] Tue, 26 December 2006 14:00 Go to previous messageGo to next message
Eclipse UserFriend
There are main 2 reasons why Java can truly run out of memory:
1. Memory leak: allocation of data structures without freeing them
2. Memory pressure: rapid allocation/deallocation of data structures
causing, the garbage collector cannot keep up collecting the deallocated
objects

Adding more memory of fiddling with the settings cannot fix above
problems, they can only post-pone them.

Some things I think you should be aware of to avoid the problems
described above are:
2.1. Expensive or buggy finalizers (look for classes with explicit
"finally()" implementations)
2.2. Native calls (especially those with custom implementations)

In case you still have no clue what goes wrong, the only thing left to
do is run a memory profile.
Whatever it is you're doing to cause the OutOfMemoryErrors, run a memory
profile of it. A good profiler is e.g. JProfiler.

Inspect the memory footprint, if you're lucky the thing that is eating
up all the memory should stick out clearly.

Peter

Thorbjørn Andersen wrote:
> James Adams skrev den 25-12-2006 03:09:
>
>> mind that Eclipse is the only program I run on this system which
>> crashes because it runs out of memory, and it happens when there is a
>> full 1Gb or more of memory to spare. Fortunately when this sort of
>> crash happens
>
> It is not because your JVM cannot get any more memory from your
> operating system, but because some internal data structure to the JVM
> runs full.
>
> I have never seen this message so I was wondering if perhaps it is your
> basic Java installation or work pattern that is different from mine.
>
> What does "java -version" and "java -fullversion" report on your system?
> Could you elaborate on what you actually DO with Eclipse?
>
> Could you try the new Java 1.6 from Sun?
>
Re: How to prevent out of memory errors? [message #239246 is a reply to message #239241] Tue, 26 December 2006 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kwarner.uneedspeed.net

Peter,

About JProfiler, it costs $499!!! Do you (anyone) know of another profiler that plugs into Eclipse???


Peter De Maeyer wrote:

>
> In case you still have no clue what goes wrong, the only thing left to
> do is run a memory profile.
> Whatever it is you're doing to cause the OutOfMemoryErrors, run a memory
> profile of it. A good profiler is e.g. JProfiler.
>
> Inspect the memory footprint, if you're lucky the thing that is eating
> up all the memory should stick out clearly.
>
> Peter
Re: How to prevent out of memory errors? [message #239250 is a reply to message #239209] Tue, 26 December 2006 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: james_adams.yahoo.com

Thanks Thorbjørn.

Lately I've been developing an application which uses Spring, Hibernate,
and JMS. I typically launch many JUnit/DbUnit tests which may incorporate
an embedded ActiveMQ broker and/or an in-memory HSQLDB database. My DAO
tests may also connect with an Oracle DataSource. I use
Subversion/Subclipse for checking in code. Overall I don't think I'm
doing anything out of the ordinary.

java -version:
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b199)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

java -fullversion:
java full version "1.6.0_01-b199"

My Windows XP JAVA_HOME environment variable is set to a 1.5 JDK base
directory since I am using Java 1.5 for my development.

My JRE preference setting in Eclipse was set to a 1.5 JRE, and I have now
changed it to the 1.6 JRE, which will hopefully make some difference.


--James



Thorbjørn Andersen wrote:

> James Adams skrev den 25-12-2006 03:09:

>> mind that Eclipse is the only program I run on this system which crashes
>> because it runs out of memory, and it happens when there is a full 1Gb
>> or more of memory to spare. Fortunately when this sort of crash happens

> It is not because your JVM cannot get any more memory from your
> operating system, but because some internal data structure to the JVM
> runs full.

> I have never seen this message so I was wondering if perhaps it is your
> basic Java installation or work pattern that is different from mine.

> What does "java -version" and "java -fullversion" report on your system?
> Could you elaborate on what you actually DO with Eclipse?

> Could you try the new Java 1.6 from Sun?
Re: How to prevent out of memory errors? [message #239255 is a reply to message #239250] Tue, 26 December 2006 17:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

James Adams wrote:
> Thanks Thorbjørn.
>
> Lately I've been developing an application which uses Spring, Hibernate,
> and JMS. I typically launch many JUnit/DbUnit tests which may
> incorporate an embedded ActiveMQ broker and/or an in-memory HSQLDB
> database. My DAO tests may also connect with an Oracle DataSource. I
> use Subversion/Subclipse for checking in code. Overall I don't think
> I'm doing anything out of the ordinary.
>
> java -version:
> java version "1.6.0_01"
> Java(TM) SE Runtime Environment (build 1.6.0_01-b199)
> Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

If you are using Eclipse 3.2 under the 1.6 JVM, that could be the source
of your problems. For one thing, I'm pretty sure Eclipse does not
officially support (ie, not tested with) the 1.6 JVM. For another thing,
the PermGen memory options to java.exe may have changed with the newer
JVM. All of the discussion around PermGen space I have seen as been
about 1.4 and 1.5 JVMs.
Double-check that the way you increase PermGen space is the same for 1.6
as it was for 1.5.


> My Windows XP JAVA_HOME environment variable is set to a 1.5 JDK base
> directory since I am using Java 1.5 for my development.

JAVA_HOME system env variable has no affect on Eclipse, unless for some
reason the default JVM on your system uses it under the covers. Did you
heed the earlier advice to specify a -vm in your eclipse.ini or in the
shortcut to eclipse.exe? Doing so is the first recommendation to people
having JVM troubles with Eclipse.


> My JRE preference setting in Eclipse was set to a 1.5 JRE, and I have
> now changed it to the 1.6 JRE, which will hopefully make some difference.

The JRE preferences in Eclipse do not affect the JVM that Eclipse is
running in itself. Those settings are for running programs you launch
from Eclipse.

Hope this helps,
Eric
Re: How to prevent out of memory errors? [message #239260 is a reply to message #239255] Tue, 26 December 2006 23:11 Go to previous message
Eclipse UserFriend
Originally posted by: james_adams.yahoo.com

Eric you make very good points about this perhaps being an issue with Java
1.6. I don't remember this sort of thing happening before I installed
this latest version of Java. I have set the -vm argument to a 1.5 version
Java VM, and will revert back to the 1.5 JRE setting within Eclipse for
good measure and then see what happens. If I continue to get out of
memory errors I will post again. Thanks to all for the help and insight.


--James



Eric Rizzo wrote:

> James Adams wrote:
>> Thanks Thorbjørn.
>>
>> Lately I've been developing an application which uses Spring, Hibernate,
>> and JMS. I typically launch many JUnit/DbUnit tests which may
>> incorporate an embedded ActiveMQ broker and/or an in-memory HSQLDB
>> database. My DAO tests may also connect with an Oracle DataSource. I
>> use Subversion/Subclipse for checking in code. Overall I don't think
>> I'm doing anything out of the ordinary.
>>
>> java -version:
>> java version "1.6.0_01"
>> Java(TM) SE Runtime Environment (build 1.6.0_01-b199)
>> Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

> If you are using Eclipse 3.2 under the 1.6 JVM, that could be the source
> of your problems. For one thing, I'm pretty sure Eclipse does not
> officially support (ie, not tested with) the 1.6 JVM. For another thing,
> the PermGen memory options to java.exe may have changed with the newer
> JVM. All of the discussion around PermGen space I have seen as been
> about 1.4 and 1.5 JVMs.
> Double-check that the way you increase PermGen space is the same for 1.6
> as it was for 1.5.


>> My Windows XP JAVA_HOME environment variable is set to a 1.5 JDK base
>> directory since I am using Java 1.5 for my development.

> JAVA_HOME system env variable has no affect on Eclipse, unless for some
> reason the default JVM on your system uses it under the covers. Did you
> heed the earlier advice to specify a -vm in your eclipse.ini or in the
> shortcut to eclipse.exe? Doing so is the first recommendation to people
> having JVM troubles with Eclipse.


>> My JRE preference setting in Eclipse was set to a 1.5 JRE, and I have
>> now changed it to the 1.6 JRE, which will hopefully make some difference.

> The JRE preferences in Eclipse do not affect the JVM that Eclipse is
> running in itself. Those settings are for running programs you launch
> from Eclipse.

> Hope this helps,
> Eric
Previous Topic:Auto clean up
Next Topic:dumb java editor question
Goto Forum:
  


Current Time: Sun Nov 09 14:13:37 EST 2025

Powered by FUDForum. Page generated in 0.04709 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top