I am writing OS independent lockless queue, so far it works great, but there is small problem with memory managment. I am not sure if its gcc problem or mine. Problem: Memory increases when element is added to list, but when element is removed from list (free(elementPointer);) memory usage don't change.
BUT when I use pthreads, N producers and M consumers (1<N<20, 1<M<20)
memory usage is about ~10mb all the time (when trying to add and remove ~10kk elements), so looks like free is working.
And funny thing is that in VS 2010 (same code, no threads) free works fine, memory is released (watched task manager).
I made test, added 1kk elements, after adding all, removed one by one all elements (no threads).
Linux - 0.08 seconds
Windows ~57 seconds
Linux(without free) - 0.07 seconds
Windows(without free) - 0.9 seconds
So, the question is, why memory isn't freed in Linux C when no threads are used ? I can post code if necessary .
GCC version: 4.4.3