Adding to Piwi's answer, sometimes your program will require Callgrind to use a bigger brk segment (up to GBs, depending on your implementation).
To modify the hardcoded limit, go to function VG_(ii_create_image)
in coregrind/m_initimg/initimg-linux.c
(around line 1000), change the following lines according to your needs
//--------------------------------------------------------------
// Setup client data (brk) segment. Initially a 1-page segment
// which abuts a shrinkable reservation.
// p: load_client() [for 'info' and hence VG_(brk_base)]
//--------------------------------------------------------------
{
SizeT m1 = 1024 * 1024;
SizeT m8 = 8 * m1;
SizeT dseg_max_size = (SizeT)VG_(client_rlimit_data).rlim_cur;
VG_(debugLog)(1, "initimg", "Setup client data (brk) segment\n");
if (dseg_max_size < m1) dseg_max_size = m1;
if (dseg_max_size > m8) dseg_max_size = m8;
dseg_max_size = VG_PGROUNDUP(dseg_max_size);
setup_client_dataseg( dseg_max_size );
}
and rebuild valgrind.
m8
is the max brk segment size that callgrind will try to allocate
There are similar pieces of code for FreeBSD and Solaris, but not macOS.