Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: arton Tajima
RE: garbage collection [ reply ]  
2010-06-12 12:31
Hi,
I believe you only need to call GC.start for invoking ruby's gc to collect rjb's unused objects those refer the Java objects.

Regards

By: Takeshi Ito
garbage collection [ reply ]  
2010-06-11 16:12
Hi,

Is there any way we can trigger the JAVA garbage collector as soon as we want?

The situation is:
I get a JAVA ArrayList which contains a large amount of data, do some analysis on the data, and then get next data set of the same kind.

The code looks like the following.
> 100.times do |i|
> j_array_list = java_function_that_get_data(i)
> ## do some analysis here
> end

Since the data returned by 'java_funcion_that_get_data' is large, I want to free memory each time. Currently, however, the memory usase increases as each loop finishes.

I tried the following, none of which worked:
+ j_array_list.clear
+ j_array_list = nil

I am using rjb-1.2.1, Java-1.6.0-12, on CentOS, ruby-1.9.1p376.

I appreciate any help from experts.
Thank you.
Takeshi Ito