BWTAResult never cleaned up

Issue #6 resolved
Former user created an issue

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)

  1. Sergey Semushin

    Sorry for creating this issue as anonymous :) I may send pull request for fixing it myself but a bit later.

  2. Alberto Uriarte repo owner

    Thanks for finding that. Could you please point me what structures are never cleaned?

  3. Sergey Semushin

    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.

  4. Sergey Semushin

    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 :)

  5. Alberto Uriarte 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 😛

  6. Sergey Semushin

    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.

  7. Log in to comment