3 ms·
From the OP: Memory Management eC already takes care of many aspects of memory management through reference counting. However, it does not automatically manag
by temporarely 3y ago
From the OP:
Memory Management
eC already takes care of many aspects of memory management through reference counting. However, it does not automatically manage [memory] allocated with the new operator, which must be manually freed with the delete operator. Furthermore, to avoid the overhead and recognizing the limits of reference counting, reference count increments and decrements is left to the user, except for the initial construction (at instantiation) and destruction of the object (when it goes out of scope). At the moment this automatic behavior is also limited to global and member instances, other instances currently start with a 0 reference count and must be manually destroyed with delete.
[edited]
This is definitely a weak point in the language.
- Kwpolska 3y agoI don’t understand this paragraph. How does it do reference counting if the developer needs to manually increment and decrement the counter? Does the language provide anything beyond automatically allocating an integer and initializing it to 1?
- temporarely 3y agotbh self-censored a couple of snarky comments regarding the same. I had trouble parsing it as well.
- jerstlouis3 3y agoI realize this is not super clear, and in fact we have an open issue to improve on where reference counting are done automatically. At the moment, only global and member instances get automatically incremented/decremented. There is a plan to extend that to local instances as well. But also `delete object` will automatically decref and delete if reaching 0. In practice, this all saves a lot of manual allocation/deallocation efforts compared to plain C, but it's all fairly low level (which was by design).