title: jemalloc using jeprof to generate gif from '*.heap' files
body: <p>First of all the purpose of the jemalloc (within my usecase) is to trace native memory allocations caused by things like JNI invocations, so let's begin:</p>
  
  <p>Hello guys I have some serious issue here. We happen to have a memory leak in one of our applications. It is located in the JNI library in particular for those of you who know it - cplex. I already know that but since our manager asked me to get a proof now I am spending horrendously loads of time trying to get one. I have come across a monster tool (yes I know it is not just a tool) called jemalloc that supposed to create "<em>.heap" files and that is great, I managed although I cannot see any way to actually read anything sensible from that file, here is the example:<a href="https://i.stack.imgur.com/mAZKd.png" rel="nofollow noreferrer">PNG image of the generated "</em>.heap" file - first few lines only but it all looks pretty much like that</a></p>
  
  <p>Than I have found out that there is that other monster called "jeprof" that apparently can convert that "<em>.heap" file to the nice "</em>.gif" - all you have to do is to run command like this: <code>jeprof --show_bytes --gif /path/to/jvm/bin/java jeprof*.heap &gt; /tmp/app-profiling.gif</code> and it should have resulted in something like example (and description) here: <a href="https://gdstechnology.blog.gov.uk/2015/12/11/using-jemalloc-to-get-to-the-bottom-of-a-memory-leak/" rel="nofollow noreferrer">https://gdstechnology.blog.gov.uk/2015/12/11/using-jemalloc-to-get-to-the-bottom-of-a-memory-leak/</a>
  (you need to scroll the page down to the section "JEMALLOC to the rescue" to see the example of the gif I am talking about).</p>
  
  <p>Unfortunately there is exactly 0 information on how to actually use it, aside of blogs like the one I have included. Every time I try to generate that gif using the exact command as: <code>jeprof --show_bytes --gif java jeprof.out.14441.5.i5.heap &gt; ../../../sheetchallenger/temp/app-profiling_14_10.gif</code> - I get the following answer and an empty gif being created having 0 bytes in size:</p>
  
  <pre><code>Use of uninitialized value $line in substitution (s///) at /usr/local/bin/jeprof line 3256.
  http://jeprof.out.14441.5.i5.heap/pprof/symbol doesn't exist
  </code></pre>
  
  <p>Here is the "jeprof" file it seems to be talking about (I mean the section around the line 3256):  </p>
  
  <pre><code>sub CheckSymbolPage {
    my $url = SymbolPageURL();
    my $command = ShellEscape(@URL_FETCHER, $url);
    open(SYMBOL, "$command |") or error($command);
    my $line = &lt;SYMBOL&gt;;
    $line =~ s/\r//g;         # Line:3256: turn windows-looking lines into unix-looking lines
    close(SYMBOL);
    unless (defined($line)) {
      error("$url doesn't exist\n");
    }
  
    if ($line =~ /^num_symbols:\s+(\d+)$/) {
      if ($1 == 0) {
        error("Stripped binary. No symbols available.\n");
      }
    } else {
      error("Failed to get the number of symbols from $url\n");
    }
  }
  </code></pre>
  
  <p>Literally no idea what is this trying to tell me, why does it use http? What for? I get that there is no profile created of some sort, or so it seems to be saying but what profile, where, how?</p>
  
  <p>Perhaps it will be of help to mention that the first time I ran this "jeprof heap file to gif converting command" I have received the following response:</p>
  
  <pre><code>[root@mnd-dev-kfk01 sheetchallenger]# jeprof --show_bytes --gif java jeprof.out.12077.129.i129.heap &gt; temp/app-profiling_11_24.gif
  Using local file jeprof.out.12077.129.i129.heap.
  The first profile should be a remote form to use /pprof/symbol
  </code></pre>
  
  <p>What on earth does that mean and why should I care - is this important, what remote form, form of what, for what?</p>
  
  <p>So basically the question is: <strong>since I can already generate those unfortunate "*.heap" files</strong> (please somebody correct me if these files don't seem to be correct) <strong>how on earth can I convert them to something useful preferably using jeprof or anything else?</strong> </p>
  
  <p>Can I convert them to that gif as shown on this site I have linked above (<a href="https://gdstechnology.blog.gov.uk/2015/12/11/using-jemalloc-to-get-to-the-bottom-of-a-memory-leak/" rel="nofollow noreferrer">https://gdstechnology.blog.gov.uk/2015/12/11/using-jemalloc-to-get-to-the-bottom-of-a-memory-leak/</a>) or can I do anything else with them? </p>
  
  <p>Kind Regards to all of you and hopefully somebody can help me figure this thing out.</p>