Using Multi-Heaps for Automatic Memory Management #22013
Closed
JoanaBLate
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Multi-Heaps has a very simple mechanism:
Each function has its own exclusive arena like heap. When the function returns, its heap is automatically released (in the same way as its stack memory is automatically released).
Data that should return to the caller (previous function) is created in the heap (or stack) of the caller. There are 3 ways to do this:
2.1) The caller function sends a reference to its own heap as an argument.
2.2) The data to be returned is created in the caller function, and its reference is passed as an argument.
2.3) This works like the style in '2.2' but is done under the hood, whoever reads the code sees functions returning values normally.
Some special cases could require memory deallocation before the function exits, but I don't see them conflicting with the arena.
This strategy seems very easy to be created in a compiler.
And even more simple for the developer. It is like writing code for garbage collected language.
I suspect that it must have problems that I am not realizing, or else someone already would be doing it.
Can you folks point out what I am missing?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions