---
name: "malloc_size"
section: "3"
platform: "macos"
package: "libmalloc"
version: "812.100.31"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/malloc_size"
---

# malloc\_size(3)

memory allocation information

## NAME

**malloc\_good\_size**, **malloc\_size** – memory allocation information

## SYNOPSIS

**#include \<malloc/malloc.h\>**

*size\_t*\

**malloc\_good\_size**(*size\_t size*);

*size\_t*\

**malloc\_size**(*const void \*ptr*);

## DESCRIPTION

The **malloc\_size**() function returns the size of the memory block that backs the allocation pointed to by *ptr*. The memory block size is always at least as large as the allocation it backs, and may be larger.

The **malloc\_good\_size**() function rounds *size* up to a value that the allocator implementation can allocate without adding any padding; it then returns that rounded-up value.

## SEE ALSO

[malloc(3)](/malloc/3.md)
