On Fri, Sep 24, 2010 at 4:38 PM, James Carroll <jlcarr...@gmail.com> wrote:

> I am not very familiar with Java aside from the few projects they had us do
> in Java back at BYU... but I am writing in Java currently because that is
> what the people around me know.
>
> Anyway, I was writing some quick and dirty idea prototype code, and I had a
> bunch of nested loops, and I had to create some objects inside the loops,
> and then, theoretically, they should get garbage collected automatically
> right? Anyway, because the loops were running fast enough, I assume that
> object creation got ahead of garbage collection, and I got:
>
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
>
>
1) If you're worried about garbage collection then Java isn't the right
Language for the job. Try C or something that has more rigid memory
control.

 2) Increasing the Heap size is an excellent idea if your objects really do
get very large, and the task is very predictable.

3) not seeing code or psudo code is hard.  There may be another way to do
what you need with better code.

4) Calling the gc from within the program still will not guarantee that it
will run.  The java VM will still give program threads priority over GC.  If
your program is still actively adding data to the Heap without breaks, then
it will block the GC.


-- 

   ~ Mark
         Gardner ~
If it were easy everyone would do it.  Hard is what keeps out the riffraff.
***
--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info (unsubscribe here): http://uug.byu.edu/mailman/listinfo/uug-list

Reply via email to