0

I'm writing a wrapper to Lucene. When a search request is made frequently, it's possible "Could not reserve enough space for object heap" will be thrown. How can I get the size of the object heap? And how can I solve that?

jzd
  • 23,473
  • 9
  • 54
  • 76
Eugeny89
  • 3,797
  • 7
  • 51
  • 98
  • 1
    possible duplicate of [Could not reserve enough space for object heap](http://stackoverflow.com/questions/4401396/could-not-reserve-enough-space-for-object-heap) (Duplicate even has the same title ;) ) – Andreas Dolk Apr 05 '11 at 10:55
  • well, the title is same but the situation is differen. User in the referenced duplicate get's the error each time. While here we have trouble if only we're launchind indexer frequently – Eugeny89 Apr 05 '11 at 11:01
  • but the solutions may fit: fragmented memory prevents from creating a sufficient object heap. What's your OS? 32 bit windows systems have some unsuspected limitations regarding heap size... – Andreas Dolk Apr 05 '11 at 11:03
  • System is: uname -a Linux 2.6.18-14-fza-amd64 #1 SMP Mon Jan 5 17:36:46 UTC 2009 i686 i686 i386 GNU/Linux I tried to specify max size of heap(even minimum size) that didn't help. – Eugeny89 Apr 05 '11 at 11:12

1 Answers1

2

I believe that the underlying problem is the same as is described in the good answers to the SO question Could not reserve enough space for object heap.

That is, the JVM is attempting to ask the OS for memory for the heap, and the OS is refusing because it has already allocated all virtual memory to other processes.

I expect that this happens when you launch the indexer frequently because:

  • it is increasing the system average load (number of processes running / waiting to run), and therefore
  • it is increasing the system's average committed virtual memory resources, and therefore
  • it is making it more likely that the OS has to say "No" when a new JVM starts to run the indexer.

Of course, this is largely conjecture ...


What can you do about it?

  1. Increase the size of the disc file or partition used for paging.
  2. Add more physical memory to the machine.
  3. Run the indexer less often and / or when the system is not busy.
  4. Trim the size of the indexer's heap.
  5. Move some of the other load off onto another machine.

Some of these need to be done with care, because they could impact on overall system performance in various ways.

(Incidentally, I don't think that switching to a 64 bit OS will necessarily help, and running a 64 bit JVM certainly won't help ...)

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Well, I executed "free -m". the metter of the fact is that there only 256Mb of memory on test server. – Eugeny89 Apr 05 '11 at 11:40