I created an object which has few integer variables, and one char memory block say which is allocated with memory of 300-500 bytes as its members . After that this object was pushed in to vector by one thread, and then another thread which is running parallel will swap with one empty vector and start processing the vector which contains the object, after processing I used to delete the char block used in object and also finalized the object and deletd the object also. But it seems the memory was not freeing up. I ran this block of code with valgrind tool it doesn't show any leak. Please help me with the solution
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
But it seems the memory was not freeing up.
How are you determining that exactly? I assume incorrectly. Calling delete whatever
marks that memory as deallocated and free for future use. The language doesn't specify exactly what that means. Your OS is better at managing memory than you are. It isn't forced to, for example, ensure that whatever tool (task manager?) you are using to measure memory usage now sees X more free bytes.
The memory you were using is now free to be allocated again. That's what you need to be concerned with, let the OS's memory manager worry about the details.