Questions tagged [memory-management]
For questions related to managing memory in programming languages, whether manually or automatically.
10
questions
3
votes
0
answers
193
views
Is there a downside to using offsets instead of raw pointers in a virtual machine?
Say I'm designing a virtual machine for a bytecode compiler/interpreter, using C as the implementation language. Some kind of “tagged” representation of values is simplest for this language, where ...
3
votes
6
answers
478
views
Are there languages or compilers having optimizations to deallocate variables early?
In a scope that defines two variables a and b, the code firstly does things only on a. Then <...
6
votes
4
answers
574
views
If garbage collection always sacrifice performance in multi-threaded languages, then how do some languages approch this problem?
Mark-and-Sweep garbage collection need to work over the graph of all objects in the process, and would stall threads to make the operation safe with regard to threads. I can think of no way to work ...
21
votes
2
answers
4k
views
To box or not to box? (how to determine if a value can be more efficiently passed by value or by reference)
I want to remove explicit addressing from my type system.
In low level languages like C or Rust, you always have a choice whether to store some data by value or by reference. There are some advantages ...
12
votes
1
answer
315
views
What was the rationale for making realloc(ptr, 0) have UB in C23
This is the first breaking change that C made, which was making realloc(ptr, 0) have UB instead of being roughly equivalent to ...
2
votes
1
answer
246
views
Are there languages making addresses to have other significant meaning?
Some examples:
To support checking whether an object is of a subclass of a specific class in constant time, in a language using single inheritance, the compiler could arrange the vtables of classes ...
16
votes
6
answers
3k
views
Possible to mix garbage collection and manual memory management?
Do you think it is possible to have a language that uses garbage collection (GC) by default, but allows you take more control with manual memory management like C++ or Rust, in areas of the software ...
3
votes
1
answer
353
views
X86-64 Assembly for Recursive Functions
A compiler I'm writing generates the following x86-64 assembly (AT&T syntax) for a recursive factorial function. I convert the assembly into an ELF executable using ...
12
votes
2
answers
553
views
Why did Objective-C remove `NSZone`?
NSZone is a type representing a memory allocation. NSObject implements the allocWithZone: ...
6
votes
3
answers
824
views
Why might a language avoid reallocation?
In Java, the size of arrays are immutable. However, to my understanding, they are still allocated on the heap, because Java allocates almost everything on the heap. Even then, Java arrays are still ...