---
name: "nng_free"
section: "3"
platform: "linux"
package: "libnng-dev"
version: "1.10.1-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/nng_free"
---

# nng\_free(3)

free memory

## NAME

nng\_free - free memory

## SYNOPSIS

```
#include <nng/nng.h>
void nng_free(void *ptr, size_t size);
```

## DESCRIPTION

The `nng_free()` function deallocates a memory region of size *size*, that was previously allocated by `nng_alloc()` or `nng_recv()` with the `NNG_FLAG_ALLOC` flag.

**Important**\

It is very important that *size* match the allocation size used to allocate the memory.

**Important**\

Do not attempt to use this function to deallocate memory obtained by a call to the system `malloc()` or `calloc()` functions, or the C++ `new` operator. Doing so may result in unpredictable behavior, including corruption of application memory.

## RETURN VALUES

None.

## ERRORS

None.

## SEE ALSO

[nng\_alloc(3)](/nng_alloc/3.md), [nng\_recv(3)](/nng_recv/3.md), [nng(7)](/nng/7.md)
