358
358
MALLOPT(m_libc_dot_so_star, mallopt);
361
// Documentation says:
362
// malloc_trim(size_t pad);
364
// If possible, gives memory back to the system (via negative arguments to
365
// sbrk) if there is unused memory at the `high' end of the malloc pool.
366
// You can call this after freeing large blocks of memory to potentially
367
// reduce the system-level memory requirements of a program. However, it
368
// cannot guarantee to reduce memory. Under some allocation patterns,
369
// some large free blocks of memory will be locked between two used
370
// chunks, so they cannot be given back to the system.
372
// The `pad' argument to malloc_trim represents the amount of free
373
// trailing space to leave untrimmed. If this argument is zero, only the
374
// minimum amount of memory to maintain internal data structures will be
375
// left (one page or less). Non-zero arguments can be supplied to maintain
376
// enough trailing space to service future expected allocations without
377
// having to re-obtain memory from the system.
379
// Malloc_trim returns 1 if it actually released any memory, else 0. On
380
// systems that do not support "negative sbrks", it will always return 0.
382
// For simplicity, we always return 0.
383
#define MALLOC_TRIM(soname, fnname) \
385
int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( SizeT pad ); \
386
int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( SizeT pad ) \
388
/* 0 denotes that malloc_trim() either wasn't able \
389
to do anything, or was not implemented */ \
393
MALLOC_TRIM(m_libc_dot_so_star, malloc_trim);
361
396
#define POSIX_MEMALIGN(soname, fnname) \
363
398
int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void **memptr, \
428
463
PANIC(m_libc_dot_so_star, pvalloc);
429
464
PANIC(m_libc_dot_so_star, malloc_stats);
430
PANIC(m_libc_dot_so_star, malloc_trim);
431
465
PANIC(m_libc_dot_so_star, malloc_get_state);
432
466
PANIC(m_libc_dot_so_star, malloc_set_state);