It's all about the answers!

Ask a question

Is there a way to capture the RTC free memory over time ?

long TRUONG (3654116146) | asked Jun 10 '14, 9:36 p.m.
 We are concerned with the low free memory displayed on the jts/admin server page, we have seen it often 
enough below 10%, sometimes as low as 1% as illustrated below. Want to motitor the free memory, how can we log this against time ?

 Uptime     9 hours, 58 minutes     
  Public URI     https://.....
    OK     VM Memory Usage
    Maximum Memory Allocation
   10000 MB
     Current Memory Allocation
   10000 MB
     Free Memory
   1 %

Donald Nong commented Jun 13 '14, 12:31 a.m. | edited Jun 13 '14, 12:31 a.m.

 For Java applications, unless you encounter some obvious problems such as OOME or slowness (due to excessive GC activities), the low memory availability does not mean anything. Looking from a different angle, it may be a good thing because it means the memory is well utilized and most of the objects are in memory, not in the database or on the disk. Another thing to note is that normally JVM will only start GC when the heap is full, so high memory usage is nothing to worry about.

2 answers

permanent link
Lily Wang (4.9k714) | answered Jun 12 '14, 8:58 a.m.
 If you have concern on the Java heap size usage, you can think about to enable GC log and use Garbage Collection and Memory Visualizer to analyze the memory usage.
Please have a look the link:

permanent link
Kevin Ramer (4.5k8180199) | answered Jun 12 '14, 12:49 p.m.
edited Jun 12 '14, 12:52 p.m.
I have a Perl script which I use to periodically gather memory statistics and use the results to post to a web page.  I based it off other Perl scripts that have been shared here. 

Here is a similar framework:

Here is the snipped that gets some of the info:

use XML::XPath;
 use XML::XPath::XMLParser;
use Data::Dumper;
use XML::Simple;
use Carp;
use LWP::UserAgent;
# this is not the complete file, only for demonstration purpose
sub getServiceInfo {

my ($JazzUser,$JazzPass,$JazzURI)=@_;

    my $browser = LWP::UserAgent->new();
    my $ur=$JazzURI;
    $ur =~ s/\/rootservices//;
    $browser->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
    push @{ $browser->requests_redirectable }, 'POST';
    $response = $browser->get( $ur . "/secure/service/");
    $response = $browser->post( $ur . "/j_security_check", [ j_username =>
$JazzUser, j_password => $JazzPass ], );
    carp "$url error: ", $response->status_line unless $response->is_success;
    if ($response->code != 500) {
    $URI = $ur . "/service/" ;

    $response = $browser->get($URI);
    else {

# main program
my ($id,$pw,$url);#=@ARGV;
$collected_at=scalar localtime($collected_secs);
$| = 1;
print "<h2>Jazz Server Status Collected $collected_at</h2>\n";
#print "<table class='basic-table' cellspacing='1' cellpadding='0' 'border='0'>
#<tr class='blue-med-dark'><th>URI</th><th>Version</th><th>Up Since</th><th>JVM Max</th><th>JVM Used</th><th>JVM Free</th></tr>\n";
while (<>) {
   if ($info ne "" ) {
#   print Dumper ($srvrs{$host_port_contxt});
    if (exists($srvrs{$url})) {
    $xp = new XML::XPath($srvrs{$url}->{'metrics'});
    $mm = $xp->find("/soapenv:Envelope/soapenv:Body/response/returnValue/value/maxMemory");
    foreach $x ($mm->get_nodelist) {
    $tm = $xp->find("/soapenv:Envelope/soapenv:Body/response/returnValue/value/totalMemory");
    foreach $x ($tm->get_nodelist) {
    $fm = $xp->find("/soapenv:Envelope/soapenv:Body/response/returnValue/value/freeMemory");
    foreach $x ($fm->get_nodelist) {
    $ut = $xp->find("/soapenv:Envelope/soapenv:Body/response/returnValue/value/uptime");
    foreach $x ($ut->get_nodelist) {
#        $upSince = scalar localtime($collected_secs - $upTime/1000);
        ($sec,$min,$hr,$md,$mn,$yr,$wd,$yd,$dst)=localtime($collected_secs - $upTime/1000);
        $upSince = sprintf "%04.4d/%02.2d/%02.2d %0.2d:%0.2d:%0.2d  ",$yr + 1900 ,$mn+1,$md,$hr,$min,$sec;
    $ut = $xp->find("/soapenv:Envelope/soapenv:Body/response/returnValue/value/publicURI");
    foreach $x ($ut->get_nodelist) {
    $ut = $xp->find("/soapenv:Envelope/soapenv:Body/response/returnValue/value/version");
    foreach $x ($ut->get_nodelist) {
   if ($n % 2 == 0) {
   else { $tr = "" };
   printf "%s,%s,%s,%.2f,%.2f,%.2f,%d\n",$URI,$version,$upSince,$maxMemory,$totalMemory,$freeMemory,$upTime/1000;
   #printf "<tr %s><td>%s</td><td>%s</td><td>%s</td><td>%.2f</td><td>%.2f</td><td>%.2f</td><td></tr>\n",$tr,$URI,$version,$upSince,$maxMemory,$totalMemory,$freeMemory;

As input I hand a file of the URL that I'd like to collect ( e.g.

and so on

Search this site for "ServerInfo" or IStatusRestService to find other possible examples.

Your answer

Register or to post your answer.