Jump to content
  • Advertisement
Sign in to follow this  
JonW

Memory Allocation Issues

This topic is 3740 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 have a Winsock server application that creates multiple threads using CreateThread for performing different tasks. Sometimes when I add or remove memory allocations from the different sections of code and recompile, I will get bad allocations when the program is run (the 'new' statement will return NULL). For example, by adding or removing a per-client allocation, the program will sometimes crash after a specific number of clients connect. If I change the allocations back to the way they were, dozens of clients can connect without problems. Changing to Release mode makes the problems go away, although it may just be the fact that the memory layout has changed slightly (the problem is very sensitive to small changes in how memory is allocated). What would cause memory allocations to fail in certain orders like this? Is memory becoming fragmented? I only make very few allocations before it happens. Does it have something to do with the allocations being made in a created thread? Any suggestions on how to debug the problem, or possible causes, would be much appreciated! Thanks!!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by JonW

Is memory becoming fragmented?


No

Quote:
Does it have something to do with the allocations being made in a created thread?


Possibly.

Quote:
Any suggestions on how to debug the problem, or possible causes, would be much appreciated! Thanks!!


Use proper memory management.

This is the only advice anyone can give not knowing the language,the design or seeing any of the code.

Quote:
I will get bad allocations when the program is run (the 'new' statement will return NULL)


Hopefully, this doesn't imply VC6?

Share this post


Link to post
Share on other sites
Quote:
Original post by JonW
(the 'new' statement will return NULL).


Huh? new shouldn't return NULL unless you explicitly specify nothrow. Are you using VC6 by any chance?

[edit]fixed typo[/edit]

[Edited by - fpsgamer on July 21, 2008 9:15:58 PM]

Share this post


Link to post
Share on other sites
Yes, sorry, both of you made correct assumptions... I am using C++ in Visual Studio 6.0. I should have provided more details.

The program is only using around 5MB of memory when I get memory errors, according to Task Manager. I can get much more than that if I change the allocations around.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!