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

memory leak #75

Open
Bobscorn opened this issue Oct 9, 2022 · 2 comments
Open

memory leak #75

Bobscorn opened this issue Oct 9, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Bobscorn
Copy link
Collaborator

Bobscorn commented Oct 9, 2022

In the algorithm.c file, fill_chunkmap leaves 3 chunkmaps un-free-d.
fill_chunkmap is given an input chunkmap as shown
void fill_chunkmap(chunkmap* map, vectorize_options* options) {
and then creates 3 more (such that each quadrant has it's own chunkmap it can write to without requiring a mutex).
This is shown here:

chunkmap* map2 = generate_chunkmap(map->input, *options);
Quadrant quadrant2 = {"top-right", map2, options, NEGATIVE, POSITIVE};
quadrant2.bounds.startingX = middle_width;
quadrant2.bounds.startingY = 0;
quadrant2.bounds.endingX = map->map_width;
quadrant2.bounds.endingY = middle_height; 

chunkmap* map3 = generate_chunkmap(map->input, *options);
Quadrant quadrant3 = {"bottom-left", map3, options, POSITIVE, NEGATIVE};
quadrant3.bounds.startingX = 0;
quadrant3.bounds.startingY = middle_height;
quadrant3.bounds.endingX = middle_width;
quadrant3.bounds.endingY = map->map_height;

chunkmap* map4 = generate_chunkmap(map->input, *options);
...

However the 3 newly created chunkmaps are never freed.
This doesn't matter for chunkshapes, as the 3 chunkmaps' chunkshapes are appended onto the input chunkmap, however the pixelchunks are not moved to the input chunkmap, which leaves the equivalent of 3 images worth of data leaking every call.

However again, simpling freeing these 3 maps with free_chunkmap would cause the shapes that used to be in the 3 chunkmaps to point to now freed pixelchunks, thereby causing access violations in the next steps of vectorization.

@Bobscorn Bobscorn added the bug Something isn't working label Oct 9, 2022
@DoubleCouponDay
Copy link
Owner

DoubleCouponDay commented Oct 9, 2022

we also need to take image structs by reference when creating new chunkmaps in a threading context.

@DoubleCouponDay
Copy link
Owner

DoubleCouponDay commented Oct 13, 2022

related to #55

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

2 participants