sin-ack / zigself

An implementation of the Self programming language in Zig
GNU General Public License v3.0
161 stars 5 forks source link

Fix the handle area memory leak #23

Closed sin-ack closed 1 year ago

sin-ack commented 1 year ago

As of 5652664, we're leaking up to 1MB (quite a significant amount) for each handle area creation. There are various ways we can solve this:

  1. Write proper target-specific aligned allocation methods. Requires research.
  2. Get rid of the fancy self-alignment and just do a linear backwards walk to find the chunk for a handle. Theoretically slower, but in practice most of the handles that need to find their chunk will be in the last chunk.
  3. Go one step further and get rid of the handle area entirely. After we flattened the bytecode, we need much fewer tracked heap pointers at once. Maybe we can keep a bounded set of heap tracking slots and keep that for the whole runtime?