memory leak occurs when calling hs_compile
- Dominant language
- C++
- Stars
- 5.5k
- Forks
- 816
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 2
Description
I created a test module that uses HyperScan and checked for memory leaks using an application verifier.
However, when running hs_compile, a memory leak occurs.
The memory where the leak occurs is the **MergeKey \*mk** allocated in the code below.
```
#ifndef _WIN32
engine_groups[MergeKey(left, parents)].push_back(left);
#else
// On windows, when passing MergeKey object into map 'engine_groups',
// it will not be copied, but will be freed along with
// engine_groups.clear().
// If we construct MergeKey object on the stack, it will be destructed
// on its life cycle ending, then on engine_groups.clear(), which
// will cause is_block_type_valid() assertion error in MergeKey
// destructor.
MergeKey *mk = new MergeKey(left, parents); // Memory Leak!!
engine_groups[*mk].push_back(left);
#endif
}
vector> chunks;
for (auto &raw_group : engine_groups | map_values) {
chunk(move(raw_group), &chunks, MERGE_GROUP_SIZE_MAX);
}
engine_groups.clear(); // It is not released here.
```
I confirmed that memory leaks do not occur if I put the allocations in a separate list and free them when the function ends.
Contributor guide
Assessment
This issue has not been assessed yet.