wood burning stoves*
The moose likes Beginning Java and the fly likes When will the out of memory happen? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "When will the out of memory happen? " Watch "When will the out of memory happen? " New topic
Author

When will the out of memory happen?

sampath soft
Greenhorn

Joined: Apr 13, 2007
Posts: 17
please any one tell me with example?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

OutOfMemoryError: "Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector." (Ref: API.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Originally posted by sampath soft:
please any one tell me with example?


Hi Sampath,

You can see this for a much better explanation
OutofMemoryError
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

By default, the JVM allows only 64MB of memory to be used. If this memory is nearly exhausted, the JVM tries to garbage collect as much memory as possible. If there still isn't enough memory, then the error is thrown.

Note that the error is never thrown if the JVM can prevent it.


You can assign more memory to the JVM using the -Xms and -Xmx parameters; for instance, if you use -Xmx128m (note the m at the end for MB, if you omit it it will use 128 bytes!) it will allow 128MB of memory to be used. These parameters must come before the main class name, otherwise it will be treated as a parameter to the Java program.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14104
    
  16

If you want an example...:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When will the out of memory happen?