I’m hoping someone can help me understand why my jruby process is
so much heap memory. I apologize for not being able to provide code
simple test case, but so far my attempts to recreate in a simple test
have failed. I’m hoping either someone will recognize the cause of my
problem or at least help me understand the role of ObjectProxyCache well
enough for me to narrow it down.
I mention ObjectProxyCache because I have taken a heap dump (using jmap)
looked at it in the SAP Memory Analyzer and see that
ObjectProxyCache$Segment’s are consuming the majority of my 2GB heap.
kept increasing the heap size to allow my program to complete…)
My program generates custom emails for a large number of users, and each
email is rather large. Most of this is done in ruby, with the result
a ruby string. However, the actual SMTP portion is being handled by a
class. What i pass the java class is a hash containing the various
of the mail, ie the recipient, subject, body, etc. The java class
this hash as a java Map object. Java then submits this map to a
ThreadPoolExecutor to be mailed.
I had been passing the body as a string, but soon realized that this
was being converted from utf8 to utf16 (java String) then back to utf8.
Instead, I now pass the body using s.to_java_bytes where s is the ruby
string holding the body.
What I have found is that even when the ThreadPoolExecutor’s queue is
basically empty there are still 16 ObjectProxyCache$Segment instances
of ObjectProxyCache$Entry’s each holding a byte with one of the long
They do not seem to be garbage collected, at least not efficiently.
happens after my program has been chugging along for a bit, and then my
usage rises to close to the 2GB limit I have set. I built in a throttle
where i sleep the rendering thread for 10seconds when the available heap
space drops too low, and can see that my queue of rendered emails
but the heap space is not freed.
Can anyone explain what’s going on? What causes entries to be added to
ObjectProxyCache? Is there something I can do (in either ruby or java
both) to ensure they get gc’d?
thanks in advance for any help!