5 ms·
So basically one needs to re-implement smart pointers in Javascript, right ? What are the alternative to js style GC,for a language that wouldnt want to the de
by aikah 12y ago
So basically one needs to re-implement smart pointers in Javascript, right ?
What are the alternative to js style GC,for a language that wouldnt want to the developper to use manual memory allocation.I've heard about ARC.Are there other known architectures?
- TheLoneWolfling 12y agoAs I said: a pauseless GC with a smart language implementation would be fine. ARC can work, but either requires programmers to prevent loops or needs a GC regardless. Object pools at the language level would be an alternative. (I.e. every object is allocated in a "pool", including pools. When a pool falls out of scope the entire pool is "freed". You can copy objects between pools as necessary.)
- aikah 12y agothanks for your input.
- Dewie 12y ago> Object pools at the language level would be an alternative. (I.e. every object is allocated in a "pool", including pools. When a pool falls out of scope the entire pool is "freed". You can copy objects between pools as necessary.) This might be called "memory regions" in the literature, or at least the work on using this memory management scheme in an ML (ML Kit).
- nostrademons 12y agoAlso related to arenas - the main difference is that an arena is a block region of memory from which different-sized objects are allocated, while a pool is a collection of same-sized objects. Both are pretty common techniques in C, C++, and Ada, and pools are common in high-performance Java.
- Skinney 12y agoOr just a smart language implementation. Go makes it easier to avoid heap allocation, and thus GC, since it allows you to specify if a structure resides on the heap or stack.
- outworlder 12y agoSmart pointers won't save you. Yes, they'll eliminate the need for collection, by moving the overhead from a single collection to ever construction/destruction. This may be worth it to get a constant framerate, but the overhead doesn't disappear. If anything, it could be greater: allocating from the heap usually costs more than an object allocation done by any sane VM.
- angersock 12y agoConstant framerate, even with overhead, can be preferable to random slowdowns.
- Skinney 12y agoThe way you guarantee constant framerate in both a GCed or manual environment is the same: arenas/regions/pools/buffers. Manual memory management is susceptible to memory fragmentation, which can severely slow down allocation.