How to avoid OutOfMemoryError


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: How to avoid OutOfMemoryError

  1. #1
    Join Date
    Nov 2005
    Posts
    37

    How to avoid OutOfMemoryError

    In my information retrieval project, I have to build a vector space model. There are three arrays, i.e. a string array IndexTerm[i], a string array FileName[j], and a double array weight[i][j]. The total number of the files is about ten thousand, while the number of index terms might be twenty thousand. This causes a serious problem, i.e. java.lang.OutOfMemoryError

    Could anybody tell me how to avoid this without reducing the number of files and index terms?

  2. #2
    Join Date
    Jan 2006
    Posts
    53
    There's the "MicroSoft" answer: Throw hardware at it. More RAM.

    Then there's the java.lang.management package. I have not used these classes yet, but I see things there like java.lang.management.MemoryUsage that sound tantilizing. Perhaps that will be of use.

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Look at the heap size switches available for the java runtime engine reserving memory - or use a data structure for managing your files which doesn't need to have them all in memory at the same time.

  4. #4
    Join Date
    Oct 2004
    Posts
    151

    Thumbs up

    Hi everyone,

    Quote Originally Posted by Laszlo
    Then there's the java.lang.management package. I have not used these classes yet, but I see things there like java.lang.management.MemoryUsage that sound tantilizing. Perhaps that will be of use.
    Quite interesting but after looking at those classes from what i get itss only used to monitor memory and not allocate more memory. If i have understood wrongly maybe you could ellaborate a bit in detail on the using this class to increase memory during runtime

    I had a similar problem as the OP a few months ago but what i did was to write my own application launcher. From there i would use the jar command to create another jvm but this time using the -Xmx flag thus setting the maximum amount of memory i want use but in my case it was around 800MB - 1GB. I used this way because i could not find anyway to increase the memory during runtime

    Richard West
    What type of softwares do you like and what would you pay for it?

    http://www.wizardsolutionsusa.com/fo...hread.php?t=12

  5. #5
    Join Date
    Nov 2005
    Posts
    37
    Quote Originally Posted by nspils
    Look at the heap size switches available for the java runtime engine reserving memory - or use a data structure for managing your files which doesn't need to have them all in memory at the same time.
    Thank you very much. But could you further explain how to increase the heap size if I'm using JBuilder, and how to manage the files which doesn't need to have them all in memory at the same time. Thanks.

  6. #6
    Join Date
    Jan 2006
    Posts
    53
    You can specify how large your heap will start at with the JVM command line parameter -Xms. But that will not affect the limitations on how much memory is available to the JVM. You may be able to get a little extra memory by reducing your JVM stack size with the -Xsssize command line parameter.

    As for how to manage your data, you haven't given enough information to know what in the world you're doing or how to optimize it. What is the purpose for loading ten thousand pages into RAM? Whatever you're doing, can it be done in pieces in stead of all at once?

Similar Threads

  1. Replies: 0
    Last Post: 01-16-2006, 01:44 PM
  2. how to avoid locks
    By moni_boj in forum Database
    Replies: 2
    Last Post: 04-28-2003, 10:22 AM
  3. Replies: 0
    Last Post: 06-01-2002, 09:03 AM
  4. avoid oracle client
    By Amy in forum VB Classic
    Replies: 4
    Last Post: 03-22-2002, 11:40 AM
  5. avoid mouse from moving outside form
    By basicOfbasic in forum VB Classic
    Replies: 6
    Last Post: 11-11-2000, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center