map and memory leak
I built a map using C++, which contains 1833053 string keys, and the values are strings as well. It is quite reasonable that the memory use is increased during the map constrction. But, after the map is completed, I look at another big file line by line, and treat each line as a key, aiming to find the corresponding value in the map, I don't know why the memory use is still increased when using the map (rather than building the map.)
I suspect there is some memory leak. Could anyone tell me how to sort this out?
Sounds as if you are making copies of the map or large portions of the map structure - either by design or inadvertently - during your search and/or retrieval.
Are you using oststream anywhere ? if you do not call freeze, it causes memory leaks.
I don't think it means that there is a leak. It could be paging, swapping, reallocation, etc. Some of the algorithms and member functions of std::map (I assume you meant that type of a map) also consume memory for sorting and creating local temporary copies. In short, there's no reason to worry so long as the memory is released when the map is destroyed.