File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When will the out of memory happen?

 
sampath soft
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please any one tell me with example?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want an example...:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic