Archived

This topic is now archived and is closed to further replies.

kamrann

ofstream access violations when multi-threading

Recommended Posts

kamrann    122
I keep getting access violations occurring in the constructor and destructor of an ofstream variable, usually at a line involving dynamic memory allocation/deallocation. I think its something to do with my app using multiple threads, since I dont really know when/how exactly I need to protect code/data from synchronization problems. I know its really vague but does anyone have any ideas on the most likely cause of this problem? thanks Cameron

Share this post


Link to post
Share on other sites
Shannon Barber    1681
Not all of the run-time libraries are thread-safe.
Are you using MSVC? Make sure you''re linking to the Mutlithreaded version of the dll/lib.

You can also try using _beginthreadex instead of CreateThread to make your threads.

Share this post


Link to post
Share on other sites
kamrann    122
Thanks Magmai, I was linking with the single threaded runtimes - that was it.
I''m not getting the access violations any more, but my program has taken a considerable frame rate hit (~60fps down to <50). Is that to be expected when changing to the multithreaded libs?

cheers
Cameron

Share this post


Link to post
Share on other sites