Clang_dispose taking too much time

Hi,

I am using libclang ( LLVM version 16.0.1 , not using libtooling ) to create a C++indexer.

I parse about 200 translation units of a game project. To give an idea about its size , it has 1.4 million call expressions ( including macro expansions ) , 900k functions.

I am simply calling clang_parseTranslationUnit with CXTranslationUnit_DetailedPreprocessingRecord to catch macros as well for each translation unit and walking ASTs.

My issue is that when I starting calling clang_disposeTranslationUnit , it is taking too much time ( about minutes ) .

For my indexer, I am using memory pools for fast deallocation of all memory and that helps freeing time in my code`s side.

Is it possible to use a custom allocator so that I can use pooling for libclang as well ?

Also as a secondary question, my indexer implementation and calls to libclang are all in the same executable. Would you recommend implementing an external process and fork it per translation unit instead for easier memory management , particularly asking for freeing stage ?

Many thanks