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

  • SEARCH
  • Home
  • 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 8314677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:54:04+00:00 2026-06-08T20:54:04+00:00

I saw that valgrind classifies memory leaks into: definitely lost indirectly lost possibly lost

  • 0

I saw that valgrind classifies memory leaks into:

  • definitely lost
  • indirectly lost
  • possibly lost
  • still reachable
  • suppressed

I just fixed a leak where the “possibly lost” was the main problem.

The documentation says: “possibly lost means your program is leaking memory, unless you’re doing unusual things with pointers that could cause them to point into the middle of an allocated block; see the user manual for some possible causes“

May I please know an example of “doing unusual things with pointers that could cause them to point into the middle of an allocated block” ?

I mean an example where “possibly lost” can be ignored although it is reported by valgrind. An example in which the use of pointers makes valgrind complain but at the same time the use of the pointers in that way is somehow legitimate

Thank you

  • 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-08T20:54:07+00:00Added an answer on June 8, 2026 at 8:54 pm

    Some examples of what the documentation are different libraries that have their own allocators and for which the memory returned is not directly the pointer returned by the underlying OS allocator (malloc/sbrk), but a pointer after an offset. Consider for example, an allocator that obtained some extra memory and stored meta information (maybe type information for a garbage collector…). The process of allocation and deallocation would be similar to:

    void* allocate( size_t size ) {
       metainfo_t *m = (metainfo_t*) malloc( size + sizeof(metainfo) );
       m->data = some_value;
       return (void*)(m+1);          // [1]
    }
    void deallocate( void* p ) {
       metainfo_t *m = ((metainfo_t*)p) - 1;
       // use data
    }
    void * memory = allocate(10);
    

    When valgrind is tracking the memory, it remembers the original pointer that was returned by malloc, and that pointer is not stored anywhere in the program. But that does not mean that the memory has been leaked, it only means that the pointer is not directly available in the program. In particular memory still holds the returned pointer, and deallocate can be called to release it, but valgrind does not see the original returned pointer at location (char*)memory - sizeof(metadata_t) anywhere in the program and warns.

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

Sidebar

Related Questions

I just saw that google deprecated the C2DM and replace it by GCM. On
I just recently saw that xcopy is deprecated and that Robocopy is recommended. I
I looked into the GCC STL (4.6.1) and saw that std::copy() uses an optimized
I saw that you can embed meta-data into images very much like you can
I'm trying to trim down the memory leaks of a large application. Using valgrind,
I just saw that the newer wordpress (newer meaning since the last time I
I'd just use Valgrind, but I'm forced to use Windows 7. I saw the
I recently saw that when sfml loads a font from memory by receiving a
I just saw that there is no so much documentation about sfGuardAuth groups and
I just saw that there is a Ruby to Parrot compiler called Cardinal ,

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.