Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks #4

Open
kiedtl opened this issue Feb 14, 2024 · 2 comments
Open

Fix memory leaks #4

kiedtl opened this issue Feb 14, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@kiedtl
Copy link
Owner

kiedtl commented Feb 14, 2024

Currently, basically no memory is ever freed. The allocator isn't even deinit'd.

Start out by writing routines for recursively freeing ASTNode's, then start deinit'ing the GPA, and piping the output traces through less to find out what else is not being deallocated.

@kiedtl kiedtl added the bug Something isn't working label Feb 14, 2024
@kiedtl
Copy link
Owner Author

kiedtl commented Sep 1, 2024

  • SmolStr/CompactString implementation in Zig
  • Analysis with Heaptrack

@kiedtl
Copy link
Owner Author

kiedtl commented Sep 13, 2024

Worked a bit on this. From analysing allocator deinit stderr output, unfreed allocations are down from 12752 unfreed allocations (before work began), to 6178 unfreed allocations, to 418.

Most of the remaining unfreed allocations seems to be coming from TypeInfo's and random lexer/AST nodes that seem to have been orphaned(?).

Note to future self: create a Box type of the form

pub fn Box(comptime T: type) type {
    return struct {
        const Inner = struct {
            allocation: T,
            freed: bool = false,
        }
        inner: *Inner,
    };
}

that tracks whether an allocation has been freed or not. Then, use it in TypeInfo for Fn, AnySet, Of, Expr.Fn, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant