October 25th, 2010, 03:35 PM
Problem with pthreads and memory management
Hello ! I'm new there, long time lurker though.
I started a week ago to code a Mandelbrot / Buddhabrot renderer (I have poor C++ skills). Then, I decided this week-end to make my program running on multiple CPU cores. I managed to get the code done, but it crashes randomly, and more frequently the more you add simultaneous threads.
gdb on mac has this recurrent error when the code decides to crash :
*** set a breakpoint in malloc_error_break to debug
test(3964,0xb0103000) malloc: *** error for object 0x102ae00: pointer being freed was not allocated
(I code on windows, though)
It seems I lack a correct memory management, but I have absolutely no idea where (tried a few things). You can edit the number of threads running at line 197. My hunch is that the problem lies with the "new" i do at line 200. I need this pointer in order to pass it as an argument to the method called by the thread, so that the method can write its part of the image directly from the thread.
If somebody could help me, it would be great =) My head is kinda exploding right now =\
Thanks in advance !
(feel free to ask any questions regarding the code.)
October 25th, 2010, 04:47 PM
Re: Problem with pthreads and memory management
Your problem is most likely due to insufficient synchronization when multiple threads access (or worse, simultaneously modify) the same data.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!