Skip to main content
GameDev.net gamedev.net
🔒 Locked

ofstream access violations when multi-threading

Started by kamrann Jan 1, 2002 at 4:19 PM 1 replies 1.7k views
Original Post
kamrann
kamrann
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
Shannon Barber
Shannon Barber
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.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
kamrann
kamrann
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.