Jump to content
  • Advertisement

Archived

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

kamrann

ofstream access violations when multi-threading

This topic is 6015 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!