Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:39:17+00:00 2026-06-15T07:39:17+00:00

gperftools documentation says that libprofiler should be linked into a target program: $ gcc

  • 0

gperftools documentation says that libprofiler should be linked into a target program:

$ gcc myprogram.c -lprofiler

(without changing a code of the program).

And then program should be run with a specific environment variable:

CPUPROFILE=/tmp/profiler_output ./a.out

The question is: how does libprofile have a chance to start and finish a profiler when it is merely loaded, but its functions are not called?

There is no constructor function in that library (proof).
All occasions of “CPUPROFILE” in library code do not refer to any place where profiler is started.

I am out of ideas, where to look next?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:39:20+00:00Added an answer on June 15, 2026 at 7:39 am

    As per the documentation the linked webpage, under Linking the library, it describes that the -lprofiler step is the same as linking against the shared object file with LD_PRELOAD option.

    The shared object file isn’t the same as just the header file. The header file contains function declarations which are looked up by when compiling a program , so the names of the functions resolve, but the names are just names, not implementations. The shared object file (.so) contains the implementations of the functions. For more information see the following StackOverflow answer.

    Source file of /trunk/src/profiler.cc on Line 182, has a CPUProfiler constructor, that checks for whether profiling should be enabled or not based on the CPUPROFILE environment variable (Line 187 and Line 230).

    It then calls the Start function on Line 237. As per the comments in this file, the destructor calls the Stop function on Line 273.

    To answer your question I believe Line 132 CpuProfiler CpuProfiler::instance_; is the line where the CpuProfiler is instantiated.

    This lack of clarity in the gperftools documentation is known issue see here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Google CPU Profiling tool. http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html On the documentation it is given
What are some good end to end CPU profilers that exist for Java? Quick
Like the question says I created some .heap files using awesome google perftools and
sudo gem install perftools.rb -p http://10.10.10.10:3128 ... /usr/local/lib/ruby/1.9.1/net/http.rb:762:in initialize: Connection refused - connect(2) (Errno::ECONNREFUSED)
There is a pprof utility in google-perftools package. It is utility to convert profile
I am using google's perftools ( http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html ) for CPU profiling---it's a wonderful tool
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
As some of you might know Google provides for free great collection of tools
I'd like to parse bits of XML structured like those in the example. I
At the http://goog-perftools.sourceforge.net/doc/tcmalloc.html it is stated: CMalloc currently does not return any memory to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.