I am trying to modify the runtime to not use shared pointers and no locks. I did replace all of them to use new operator instead, so far so good, the runtime still operates correctly, but... there is a very large number of memory leaks (not surprising). What is the lifecycle of objects like ATNConfig? Where would be a safe place to delete them? Note, I also made the generated parser use non static ATN so I don't need the locks in multithread context.
Here is an example of a leak I get:
==4747== 54,736,648 (53,672,160 direct, 1,064,488 indirect) bytes in 1,118,170 blocks are definitely lost in loss record 1,519 of 1,519
==4747== at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4747== by 0xAE24F0: antlr4::atn::ParserATNSimulator::getEpsilonTarget(antlr4::atn::ATNConfig*, antlr4::atn::Transition*, bool, bool, bool, bool) (ParserATNSimulator.cpp:1050)
==4747== by 0xAE1D01: antlr4::atn::ParserATNSimulator::closure_(antlr4::atn::ATNConfig*, antlr4::atn::ATNConfigSet*, std::unordered_set<antlr4::atn::ATNConfig*, antlr4::atn::ATNConfig::Hasher, antlr4::atn::ATNConfig::Comparer, std::allocator<antlr4::atn::ATNConfig*> >&, bool, bool, int, bool) (ParserATNSimulator.cpp:894)