This line should not be here: https://github.com/mpetri/FM-Index/blob/master/FM.cpp#L127 I believe, that in C++ most people believe in RAII principle and do not expect FM index to free input string memory.