# rework memory management of Module.Namespace hash maps · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/91b897ef581aec65dd7a080754ab09d2e176ed8f)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 91b897ef581aec65dd7a080754ab09d2e176ed8f

Requested commit: 91b897ef581aec65dd7a080754ab09d2e176ed8f

Commit: 91b897ef581aec65dd7a080754ab09d2e176ed8f

Tree: 6c6a7a2a3776d579619c6ed1cda49f5392f63640

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
rework memory management of Module.Namespace hash maps

The motivating problem here was a memory leak in the hash maps of
Module.Namespace.

The commit deletes more of the legacy incremental compilation
implementation. It had things like use of orderedRemove and trying to do
too much OOP-style creation and deletion of objects.

Instead, this commit iterates over all the namespaces on Module deinit
and calls deinit on the hash map fields. This logic is much simpler to
reason about.

Similarly, change global inline assembly to an array hash map since
iterating over the values is a primary use of it, and clean up the
remaining values on Module deinit, solving another memory leak.

After this there are no more memory leaks remaining when using the
x86 backend in a libc-less compiler.

```

## Parents

- [53500a57684665e08a2e18e7a736aacfa6548062](https://git.cafe/gitcafe/zig/commit/53500a57684665e08a2e18e7a736aacfa6548062?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/91b897ef581aec65dd7a080754ab09d2e176ed8f?format=markdown)
