2 ms·
If your statics have containers(yes I know it's a bad idea, but not forbidden) then you can easily have invalid pointers now with that approach. Really you're
by vvanders 9y ago
If your statics have containers(yes I know it's a bad idea, but not forbidden) then you can easily have invalid pointers now with that approach.
Really you're going to have to go through so many gyrations that your GC code may start looking a lot like manual memory management.
- vidarh 9y agoNo, you just need to know what you're allocating and accept that if you're using an approach like that you're very much responsible for ensuring you don't allocate anything that should live on past the mark. It's an old, well tested mechanism - the brk() syscall in Unix-like systems for getting memory does just that, for example (though today some get more convoluted and may or may not opt to use mmap() as well) And you'll find it used today even in systems with gc's too. E.g. mruby for example provides an API to do pretty much that for extensions that would otherwise leave a lot of garbage to explicitly allocate to an arena and throw away everything other than whatever you then explicitly register with the gc. If you have complications like what you describe, you'd probably want a proper gc, but as I outlined elsewhere, a simple gc is also easy if your heap is small enough that performance isn't an issue. But for many systems it's not necessary.