Earlier quoted context omitted.
It's a C++ myth that files and memory are the same problem, in reality files are an easier problem, cf java.
?! Java doesn't offer a reasonable solution for files... it is presumed they can be closed by the garbage collector calling "finalizers", but that results in problems such as holding file locks long after they should have been released (which is a correctness problem) and running out of file handles (a limited resource that Java does not track pressure against) due to this mechanism having no time horizon. The result…
Untangling Lifetimes: The Arena Allocator
31–40 of 94 posts
Re: Untangling Lifetimes: The Arena Allocator
#32Earlier quoted context omitted.
> The other issue he doesn't address is resource allocation. It's fine to just drop the memory of a lot of things I think there is a fundamental difference between memory and most other resources: (process's) memory is a) effectively an internal detail while other resources are externally visible (open files/sockets/etc); b) as almost a consequence, it's pretty much anonymous: when you ask for 1 MiB of memory, you as…
So do you argue that memory is different from point of view of resourse allocation/deallocation because it is much harder to exhaust memory than file descriptors, tcp ports and such like?
And that's why automated memory management (garbage collection) is a success story while attempts to blindly apply it to other resources failed: memory is different. Freeing other resources sends a very clear message to the external environment, including other processes, which is used for IPC while freeing memory doesn't.
Yes, in the end, memory in process is implemented by (shared) physical memory but modern OSes go to ridiculous length to support the illusion that it's unlimited and private. Yes, there is shared memory mappings which I explicitly leave outside the argument: those are externally visible, nameable, and hard to manage with GC.
Re: Untangling Lifetimes: The Arena Allocator
#33This article is about 10 times longer than it needs to be. Also no need for the dripping condescension. I’m even among the most receptive to what he’s trying to say, but got exhausted after about 20% of the article and had to give up.
Re: Untangling Lifetimes: The Arena Allocator
#34The author should take another look at RIIA. The first big difference is that it works with non-memory resources too, for example open/close for files. The second is that it makes heap allocated data feel a lot like stack allocated data, since the resources are ultimately owned by variables on the stack. With “move semantics” resources can be passed as arguments and returned by functions too, so the example of lifeti…
It's a C++ myth that files and memory are the same problem, in reality files are an easier problem, cf java.
Re: Untangling Lifetimes: The Arena Allocator
#35For me as non native speaker it is interesting choice of words with 'Untangling'. While arenas achieve the goal to simplify lifetime management by reducing number of different lifetimes they do it by effectively 'entangling' lifetimes. If arenas are reused they make UAF detection a problem that needs special care. Performance is usually great so it is used everywhere not only in gamedev.
UAF would be the same difficulty as allocated arrays I would think?
Re: Untangling Lifetimes: The Arena Allocator
#36Isn't stack/arena allocation still vulnerable to dangling pointers?
The point is not perfection, it is simplicity and mapping tools to requirements.
Re: Untangling Lifetimes: The Arena Allocator
#37The author should take another look at RIIA. The first big difference is that it works with non-memory resources too, for example open/close for files. The second is that it makes heap allocated data feel a lot like stack allocated data, since the resources are ultimately owned by variables on the stack. With “move semantics” resources can be passed as arguments and returned by functions too, so the example of lifeti…
My question is: what makes this so useful? Looking at wikipedia, the focus seems to be on lifetime guarantees, but I'm having trouble understanding how these are useful in practice. Contrasting this with a non-RAII language like Go might be helpful.
Re: Untangling Lifetimes: The Arena Allocator
#38The author should take another look at RIIA. The first big difference is that it works with non-memory resources too, for example open/close for files. The second is that it makes heap allocated data feel a lot like stack allocated data, since the resources are ultimately owned by variables on the stack. With “move semantics” resources can be passed as arguments and returned by functions too, so the example of lifeti…
It's a C++ myth that files and memory are the same problem, in reality files are an easier problem, cf java.
Re: Untangling Lifetimes: The Arena Allocator
#39This article is about 10 times longer than it needs to be. Also no need for the dripping condescension. I’m even among the most receptive to what he’s trying to say, but got exhausted after about 20% of the article and had to give up.
As someone already sold on arenas I appreciated both the depth and battle story style. Perhaps the author is mis-targeting: they are preaching to the choir instead of converting the sinners =]
Re: Untangling Lifetimes: The Arena Allocator
#40Earlier quoted context omitted.
As a C programmer who uses memory arenas quite frequently can you expand on what you know about Rust’s current or future support for such a feature? I’d like to start writing new projects in Rust and I’d like to continue to use this approach to memory management!
You can of course use arenas in Rust just like in C. I think the parent was talking about support for using arenas as the memory for stuff like built-in containers (dynamic arrays, hash maps, etc.): https://github.com/rust-lang/wg-allocators
https://docs.rs/bumpalo/latest/bumpalo/#nightly-rust-allocat...
use bumpalo::Bump;
let bump = Bump::new();
let mut v = Vec::new_in(&bump);
v.push(0);
v.push(1);
v.push(2);