BWTAResult never cleaned up
If BWTA is being used in consecutive games, it's internal structures are never cleaned up so they are being read again and appeneded to the previous ones, as a result, all data becomes duplicated. Technically it is also good to remove memory that is being leaked on each run but possibility of consecutive use is more important issue.
Comments (9)
-
-
repo owner Thanks for finding that. Could you please point me what structures are never cleaned?
-
Well I mean:
std::set<Region*> regions; std::set<Chokepoint*> chokepoints; std::set<BaseLocation*> baselocations; std::set<BaseLocation*> startlocations; std::set<Polygon*> unwalkablePolygons;
I noticed it for base and start locations but haven't seen any cleanup code for the rest of them too, so probably all of them.
-
repo owner - changed status to resolved
cleaning old results, fixed
#6→ <<cset dfa9270ed32e>>
-
Thank you. I guess leaks should be removed too though I hope you don't mind if I fix them using leak check and send pull request :)
-
repo owner - changed status to open
Yes sure, just keep in mind that some pointers have multiple reference. Maybe it would be better to use std::shared_ptr. Otherwise when you close the application it will try to delete some pointers that they have been already deleted. That is why I only did a "quick" fix for now
-
repo owner - changed status to resolved
Memory leaks fixed. It should work fine now ;)
Commit 4a44c72
-
Well ok but I advise to at least add empty virtual destructors to Region, Chokepoint, BaseLocation classes and remove static casts from deletes :) Also there's still technically be leaks at the end of program which may not be a big deal but could be an issue for library's users who would like to test their module/application with leak check, it could be worked around with exposing cleanup code by encapsulating it to a function.
Using smart pointers is more correct way for solving that problem but currently I fail to see how they can be used elegantly without changing existing library interface.
-
repo owner New method BWTA::cleanMemory() to clean BWTA_Results, ref
#6→ <<cset 36291c986b8c>>
- Log in to comment
Sorry for creating this issue as anonymous :) I may send pull request for fixing it myself but a bit later.