# Rss?

**URL:** <https://www.ruby-forum.com/t/rss/181842>\
**Category:** JRuby\
**Created:** [January 19, 2010, 4:59am UTC](https://www.ruby-forum.com/t/rss/181842 "2010-01-19T04:59:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [January 19, 2010, 4:59am UTC](https://www.ruby-forum.com/t/rss/181842/1 "2010-01-19T04:59:21Z")

</div>

Is there an easy jruby way to get the rss of the current process?  
Just wondering.  
Thanks.  
-r

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [January 19, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/rss/181842/2 "2010-01-19T13:11:59Z")

</div>

I don’t know about ‘easy’, but you can use JMX to inspect the  
java.lang.Memory MBean and get information about it that way. Would that  
meet your needs? I think there is a JMX gem which might help with that.

Cheers,

James

2010/1/19 Roger P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [January 19, 2010, 5:43pm UTC](https://www.ruby-forum.com/t/rss/181842/3 "2010-01-19T17:43:37Z")

</div>

On Tue, Jan 19, 2010 at 6:11 AM, James A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I don’t know about ‘easy’, but you can use JMX to inspect the  
> java.lang.Memory MBean and get information about it that way. Would that  
> meet your needs? I think there is a JMX gem which might help with that.

Here’s an example…no JMX needed to access the beans from within the  
same process:

~/projects/jruby âž” jirb --simple-prompt

> > require ‘java’  
> > =\> true  
> > mem\_bean = java.lang.management.ManagementFactory.memory\_mxbean  
> > =\> sun.management.MemoryImpl@b0de2e  
> > mem\_bean.gc  
> > =\> nil  
> > heap\_usage = mem\_bean.heap\_memory\_usage  
> > =\> init = 0(0K) used = 3033160(2962K) committed = 5459968(5332K) max =  
> > 520290304(508096K)  
> > nonheap\_usage = mem\_bean.non\_heap\_memory\_usage  
> > =\> init = 29523968(28832K) used = 21956272(21441K) committed =  
> > 32210944(31456K) max = 121634816(118784K)  
> > mem\_bean.verbose = true  
> > =\> true  
> > ary = ; 1000.times { ary \<\< “hello” }; ary = nil; mem\_bean.gc  
> > [GC 3463K-\>2959K(5332K), 0.0017047 secs]  
> > [GC 3471K-\>2942K(5332K), 0.0011893 secs]  
> > [GC 3452K-\>2988K(5332K), 0.0011530 secs]  
> > [Full GC 3163K-\>2746K(5332K), 0.0669727 secs]  
> > =\> nil

What you’re interested in here is the committed sizes; heap plus  
nonheap should be pretty close to RSS. For more than that you could  
call out to C via FFI. I also show turning on verbose GC logging here.

There’s more fun if you want to dig deeper:

> **[java.lang.management (Java 2 Platform SE 5.0)](https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/management/package-summary.html)**

- Charlie

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [January 19, 2010, 6:36pm UTC](https://www.ruby-forum.com/t/rss/181842/4 "2010-01-19T18:36:23Z")

</div>

> > > nonheap\_usage = mem\_bean.non\_heap\_memory\_usage

Cool.  
I added its RSS as

mem\_bean.heap\_memory\_usage.used + mem\_bean.non\_heap\_memory\_usage.used

and now I can get the rss for a jruby process on doze, without win32ole  
🙂

-r
