0

I am not able to understand and analyze the profile generated using jeprof as it is not maping the symbols and showing the hex addesses I guess.

I am trying to generate the profile of following code:

#include <iostream>
#include <thread>
#include <jemalloc/jemalloc.h>
// #include <gperftools/profiler.h>


void task1()
{  for(int i=0; i<=100;i++){

    // allocate some memory using jemalloc
    void* data = malloc(sizeof(int) * 1000);
    // std::cout << "Task 1: " <<i<< " Allocated memory at address " << data << "\n";

    // do some work

    // free the memory using jemalloc
    free(data);
    // std::cout << "Task 1: Freed memory at address " << data << "\n";
}}

void task2()
{
  for(int i=0; i<=100;i++){
    // allocate some memory using jemalloc
    void* data = malloc(sizeof(int) * 1000);
    // std::cout << "Task 2: " << i<< " Allocated memory at address " << data << "\n";

    // free the memory using jemalloc
    free(data);
    // std::cout << "Task 2: Freed memory at address " << data << "\n";
  }
}

int main()
{ setenv("opt.lg_prof_sample", "15", 1);
    setenv("MALLOC_CONF", "opt.prof=true,opt.prof_prefix=profile,zero_realloc:true,narenas:8", 1);
    setenv("opt.oversize_threshold", "1000", 1); // Set oversize_threshold to 4096 bytes
    // initialize jemalloc
  // ProfilerStart("heap_profiler.log");

    // create two threads to perform tasks
    std::thread t1(task1);
    std::thread t2(task2);
    // wait for threads to finish
    t1.join();
    t2.join();
  // ProfilerStop();

    return 0;
}

Execution steps:

  1. setting the env variable for profile enabling: export MALLOC_CONF="prof:true,lg_prof_interval:25"

  2. g++ -pg pro.cpp -o file -pthread -ljemalloc

  3. ./file

  4. jeprof file jeprof.*heap using the command top100 in jeprof profile I get doesn't show the symbols: enter image description here

Huma Zahid
  • 11
  • 2

0 Answers0