Autosave: 2024-04-20 14:30:05

This commit is contained in:
thomasabishop 2024-04-20 14:30:05 +01:00
parent a4a0cfffa8
commit 66c55e149d
2 changed files with 12 additions and 1 deletions

Binary file not shown.

View file

@ -1,7 +1,7 @@
---
id: 18bl
title: Heap_memory
tags: [memory]
tags: [memory, C]
created: Saturday, April 20, 2024
---
@ -20,4 +20,15 @@ _garbage collection_. In a language like C, this is the explicit concern of the
programmer and is not abstracted away. Failure to properly manage garbage
collection is what causes [[Memory_leaks]].
Here is an example of managing heap memory allocation in C:
```c
void * data;
data = malloc(512)
```
The first line assigns a special _pointer_ variable (indicated by `void *`
rather than `int` or `str`) . This is a variable only holds a memory address.
The `malloc` method assigns 512 bytes to the `data` variable.
## Related notes