out of memory, help!

B

Bru, Pierre

hello,

when I run my program, I get a 'Exception in thread "main"
java.lang.OutOfMemoryError' but my PC still have plenty of free memory
:(

where am I wrong ?

Win2K/1GB memory

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

TIA,
Pierre.
 
C

Christophe Vanfleteren

hello,

when I run my program, I get a 'Exception in thread "main"
java.lang.OutOfMemoryError' but my PC still have plenty of free memory
:(

where am I wrong ?

Win2K/1GB memory

By default, the JVM can only use 64MB for its heap. You have to tell it that
it can use more by playing with the heap size parameters:

java -Xmx256m -jar myjar will let you use 256MB for example.

You can look at the possible parameters by running "java -help" and "java
-X".
 
M

Michael Rauscher

Hi Pierre,

hello,

when I run my program, I get a 'Exception in thread "main"
java.lang.OutOfMemoryError' but my PC still have plenty of free memory
:(

where am I wrong ?

It's not your PC that is out of memory but the virtual machine.

Try

java -Xmx128m -Xms128m ...

or even higher values.

Bye
Michael
 
C

Cycloneous Echevarria

Pierre,

Keep in mind that the Java Virtual Machine environment has default
memory settings. You have to tell the virtual machine to set aside more
memory when running your application.

If you type: java -help

It will give you the interpreter options for your application.

Orlando
 
A

Andrew Thompson

when I run my program, I get a 'Exception in thread "main"
java.lang.OutOfMemoryError' but my PC still have plenty of free memory ....
where am I wrong ?

Various people have told you how to increase
the memory size Pierre, but I think they might
be making a mistake in doing so.

It sounds to me more like you have a memory *leak*.

What are you actually _doing_?

What size are the files you are reading?
How many elements are in arrays? etcetera..
 
B

Bru, Pierre

thanks all for the -Xms and -Xmx tricks I was not aware of.

Andrew:

I'm using Webl (Compaq's Web Language,
http://research.compaq.com/SRC/WebL/) to parse, modify and create HTML
pages.

WebL is an interpreted language whose interpreter is written in
Java... so I have no control on potential memory leak, except reading
the source. BTW, this product seems to be no longer supported :(

Pierre.
 
D

Dave Monroe

Andrew Thompson said:
Various people have told you how to increase
the memory size Pierre, but I think they might
be making a mistake in doing so.

It sounds to me more like you have a memory *leak*.

What are you actually _doing_?

What size are the files you are reading?
How many elements are in arrays? etcetera..

The last time I saw one of these was when I was using the += construct
to concatenate a big string.

StringBuffer is the thing to use.

Hmmmm . . .
 
A

Andrew Thompson

Andrew Thompson wrote in message ... ...
The last time I saw one of these was when I was using the += construct
to concatenate a big string.

That's what I'm thinkin' too Dave.

I have loaded entire 10Meg astronomical
catalogs into 'a string'.

If you treat it carefully and simply
examine the string, you can do this
quite easily without a memory exception.

The += concatenation and such is
what kills it.

I almost bet that whatever construct
_is_ causing this problem (assuming
we are on the right track) is in the OP's
code rather than the unsupported library.
A library does not make it too far if
it has memory leaks.

That brings me to..
<http://www.physci.org/codes/sscce.jsp>

And, if you've read this far, it might be
a good time to add that the 'out of memory, help!'
subject of this post, combined with the
posting style, suggests you may get different
and better answers from this group ay the moment
<http://www.physci.org/codes/javafaq.jsp#cljh>
 
M

mromarkhan

Peace be unto you.

java ToHTML
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Fix:
java -Xms128m -Xmx128m ToHTML

C:\>java -X
-Xmixed mixed mode execution (default)
-Xint interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by ;>
set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by ;>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by ;>
prepend in front of bootstrap class path
-Xnoclassgc disable class garbage collection
-Xincgc enable incremental garbage collection
-Xloggc:<file> log GC status to a file with time stamps
-Xbatch disable background compilation
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
-Xprof output cpu profiling data
-Xrunhprof[:help]|[:<option>=<value>, ...]
perform JVMPI heap, cpu, or monitor profiling
-Xdebug enable remote debugging
-Xfuture enable strictest checks, anticipating future default
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni perform additional checks for JNI functions

The -X options are non-standard and subject to change without notice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top