CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Exception

  1. #1
    Join Date
    Aug 1999
    Posts
    2

    Exception

    I've almost completed a java app but somehow managed to avoid the handling of OutOfMemoryException. can someone suggest a way that i can go about handling this exception now that my app has been written almost complety. it seems that it can be thrown from anywhere in the app so i'm kinda confused as to where or how i should start. thanx a bunch!

    - p


  2. #2
    Join Date
    Apr 1999
    Location
    Bangalore,India
    Posts
    43

    Re: Exception

    Hi,
    I think u r taking about OutOfMemoryError.
    This occurs because your JVM is not able to allocate memory for objects that u have created in your program. When the JVM is started, the size of the heap(memory allocation pool) is 1MB. If all the memory is used then OutOfMemoryError will occur. So in order to prevent this u have to follow any of these things.

    1) See to that u won't create unnecessary objects. Also keep an eye on the scope of each and every variable you create. Make your objects equal to null if u won't need them. If yours is a big application, Garbage Collector will be called before your application exits and it will release the objects references which are not needed by the program.
    2) Explicity call garbage collector. But u have to careful in this case. U have see whether u have objects to be freed.
    3) Use java -Xms2M -Xmx6M className to start your application.
    ms - minimum size of heap.
    mx - max heap size.

    I hope this will help u. Sorry if it won't.

    regards,
    arun...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured