2 ms·
>I was writing an interpreter using shared ptrs all over the place. I am doing that :/ In Object Pascal it is the standard memory management way. All strings
by benibela 6y ago
>I was writing an interpreter using shared ptrs all over the place.
I am doing that :/
In Object Pascal it is the standard memory management way. All strings and arrays are reference counted, and so I use it for all my own data structures as well
I have not even added threading and I doubt I will, but the reference counting is already the slowest part
Not sure what the alternative is
- asdfasgasdgasdg 6y agoYou can avoid reference counting overhead by using handles as described in this article. Each object in a slab would have just one reference, and you handles would be indexes into an array of them. Now, after you do that you will be on be hook for making sure you don't accidentally deallocate any of the objects that is currently in use. And it's not guaranteed to be faster. But it is one way to get around this issue.
- benibela 6y agoI do not understand how this would help It would still need reference counting on the handles to know when the handle is not used anymore and the element in the array can be reused Without reusing handles it would surely run out of memory. Unless a full GC is used