Skip to content

[C++] Memory leak 'validator_map' when exiting process #889

@xamix

Description

@xamix

Hi,

I'm running Valgrind on a project which use PGV.
The project do not allow any memory leaking even when exiting the program.

In your file validate.h you create a global validator_map on heap.

However this map is never destroyed leading to error in Valgrind complaining at exit of program that it leaked.

In protobuf they provide the ShutdownProtobufLibrary function in order to deallocate every allocated object and makes memory analyzer happy.

For now to temporarly FIX that, I have added the following similar function in BaseValidator in order to cleanup this map and make Valgrind happy with no error:

  static void ShutdownValidator() {
    delete &abstractValidators();
  }

I call this function when my program exit, at the same time of the ShutdownProtobufLibrary function.

Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReports and/or fixes a bugC++C++ language support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions