> For the complete documentation index, see [llms.txt](https://docs.cherax.vip/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cherax.vip/lua-documentation/api-reference/g_memory/allocate.md).

# allocate

int allocate(int bytes)

```
ptr = g_memory.allocate(4)
g_memory.write_int(ptr, 1337)
g_memory.free(ptr)
```
