Author Topic: Valgrind and Cachegrind  (Read 2476 times)

Offline Evan

  • Multiple posting newcomer
  • *
  • Posts: 31
Valgrind and Cachegrind
« on: March 14, 2026, 03:18:53 pm »
I'm testing my C99 code, that seems to run as intended and I'm using valgrind-3.22.0. on Linux Mint 22.3 and Code::Blocks  Build: 2024-03-31
command: valgrind  --leak-check=full --track-origins=yes --xml=yes

-------------- Application output --------------

I hope that means no memory leaks and my System Monitor is not showing any leaks/peaks.


Cachegrind however gives a message: brk segment overflow in thread #1: can't grow to 0x4856000
valgrind --version
valgrind-3.22.0
valgrind  --tool=cachegrind "/home/C/Test/bin/Debug/Test"
==33537== Cachegrind, a high-precision tracing profiler
==33537== Copyright (C) 2002-2017, and GNU GPL'd, by Nicholas Nethercote et al.
==33537== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==33537== Command: /home/C/Test/bin/Debug/Kalechen
==33537==
==33537== brk segment overflow in thread #1: can't grow to 0x4856000
==33537== (see section Limitations in user manual)
==33537== NOTE: further instances of this message will not be shown
==33537==
==33537== I refs:        5,078,382,897

Any help is appreciated?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1842
Re: Valgrind and Cachegrind
« Reply #1 on: March 17, 2026, 11:58:57 am »
Quote
==33537== (see section Limitations in user manual)

Quote
On Linux, Valgrind determines at startup the size of the 'brk segment' using the RLIMIT_DATA rlim_cur, with a minimum of 1 MB and a maximum of 8 MB. Valgrind outputs a message each time a program tries to extend the brk segment beyond the size determined at startup. Most programs will work properly with this limit, typically by switching to the use of mmap to get more memory. If your program really needs a big brk segment, you must change the 8 MB hardcoded limit and recompile Valgrind.

The segment is trying to grow to 72 MB, far higher than the 8 MB limit. If you are using malloc() to allocate memory you can ignore this message.

Offline Evan

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: Valgrind and Cachegrind
« Reply #2 on: Today at 10:52:20 am »
Thanks.