I had a process on a server. My process uses a shared lib, runing in the linux background. I use CPU profiler in gperftool to examine the functions. The steps is following:
1. in my app,
main ()
{
ProfilerStart("dump.txt");
...code..
ProfilerFlush();
ProfilerStop();
return 0;
}
2. CPUPROFILE_FREQUENCY=1000000 LD_LIBRARY_PATH=/usr/local/lib/libprofiler.so CPUPROFILE=dump.txt ./a.out
3. pprof --text a.out dump.txt
I checked my steps on the other process (not using shared lib), it's ok.
Problem: The dump.txt file is just remain an unchanged file size (8kb or 9kb), can not show the output despite of long time running in 2 or 3 hours (the app receive message from clients). I think that because my app uses the shared lib, some thing wrong here, totally not clear about this.
Can you pls explain me what happened? Any solution?
Thanks a lot,
Part
LD_LIBRARY_PATH=/usr/local/lib/libprofiler.sois incorrect in your run.According to documentation http://goog-perftools.sourceforge.net/doc/cpu_profiler.html
you can either add libprofiler to linking step as
-lprofilerof your application likeor add it at with environment variable
LD_PRELOAD(notLD_LIBARY_PATHas you did):When cpu profiler of gperftools is correctly used, it will print information about event count and output file size when application terminates.