Jump to content
  • Advertisement
Sign in to follow this  
SirLuthor

Memory Manager workout..

This topic is 4841 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

Hello once again folks! I've got a favour to ask of y'all... I'm working on yet another memory manager, and I want to test it out, see if it's bulletproof (as it is one of the pieces that really be definition has to be absolutely bulletproof), and all that jazz.. So I need a good workout for it. Basically, I was wondering if anyone had on hand or could make a workout that they would use to test all facets of a memory management system. So in this case, it would for example suffice to have an all-purpose test for new/delete, which I would then mod to fit my memory manager, and use. Me being the designer, I don't like testing my code, because I fear that I have a subconsious bias towards testing things I know will work, plus I often tend to forget a few important things, which end up biting me later... Note that this will also be used in timing tests, if it pans out. Much obliged.

Share this post


Link to post
Share on other sites
Advertisement
Ok... I guess I'll give it a shot:



int * i;

void Foo()
{
char * str = new char[3000];
std::cin >> str;
}

void Bar()
{
int i = 30;
std::cout << i << "\n";
delete i;
}

void FooBar(int * i)
{
int ** array = new int[(*i)];
for (int c = 0; c < (*i); ++c)
array = new int[(*i)];
}

void BigLeak()
{
double * m = new double[100000];
}

int main()
{
(*i) = 39;
for (int q = 0; q < (*i); ++q)
Foo();
Bar();
delete i;
FooBar(i);
for (int x = 0; x < 10000; ++x)
BigLeak();
return 0;
}

Share this post


Link to post
Share on other sites
Thanks, that's exactly the sort of thing I'm looking for, just a sort of stress-test that will give me an idea of how bulletproof I am, and how my speed will compare with standard new/delete [smile] Your contribution has been duly noted and appreciated.

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!