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?
05-16-2007, 10:09 AM
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.
05-16-2007, 11:17 AM
Are you using oststream anywhere ? if you do not call freeze, it causes memory leaks.
05-16-2007, 04:06 PM
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.