简体   繁体   中英

Valgrind possibly lost memory in simple programs

Whatever program I run Valgrind tells me that there are 72 possibly lost bytes in 3 blocks, even with a simple program like:

int main(void)
{
    printf("Hello, World!\n");
    return 0;
}

Do you know if this is a Valgrind bug on Mac OS sierra?

How could I leak memory with a program like this?

That can very likely happen, if any of the preloaded libraries (eg via LD_PRELOAD ), or any parts of the linked C runtime have memory leaks.

There are also a couple of memory allocations performed by the CRT which are never freed on purpose, but typically these are only a one-time thing and only happen once per process.

Valgrind can not reliably distinguish between what's part of your application at what isn't. You can only check the stack trace from where the memory was allocated, and decide whether that is your domain or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM