Jump to content
  • Advertisement
Sign in to follow this  
myvraccount

Running out of memory prematurely

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

Sometimes I get an out of memory exception when I don't think I should.  It's been happening when I try to write a file to the hard drive.  For analytical purposes I have to have all the data loaded into ram before writing it, and it is several dozen megabytes.

 

However, I know that I have 16 gigabytes of ram and I'm hardly running any other programs, certainly not anything that would take a significant fraction of it.  Isn't memory first-come first-serve, meaning that Windows should let me have however much I need until I've used it all and then run out?

 

Also, it oddly occurs while I'm writing the file.  The data is already in ram, and I'm not allocating any more.  I thought that the only thing that could cause that exception was a memory allocation, or am I wrong?

 

And by the way, I know that the stream and everything is working, because if I use smaller files with the same function, it works fine.  The problem only happens when I use a huge file, and it tends to happen late in the process when it's near the end of writing the file.

Share this post


Link to post
Share on other sites
Advertisement

Firstly, you've been told before not to throw all your questions into For Beginners. I'm moving this to the general programming forum.

Secondly, show code, and explain exactly what this exception is that you see. We're not here to second-guess what you're doing which may or may not be wrong.

 

Share this post


Link to post
Share on other sites
3 hours ago, Kylotan said:

Firstly, you've been told before not to throw all your questions into For Beginners. I'm moving this to the general programming forum.

 

OK, sorry.  I wasn't sure where it belonged because it seems like a relatively simple problem and people used to keep telling me that the things I post should be moved to beginners.  So for future reference, what kinds of things are intended for the beginners forum?

 

3 hours ago, Kylotan said:

Secondly, show code, and explain exactly what this exception is that you see. We're not here to second-guess what you're doing which may or may not be wrong.

I don't know why everyone ALWAYS expects me to post code.  Yes, I understand that in many cases it can be more convenient, but doesn't anyone else understand the concept of confidentiality?  I narrowed the problem down to a specific line.  I KNOW for certain that nothing else is causing it either directly or indirectly, because as I said, the stream works for all but the largest files.  And all the line does it write data from an already existing array into a file.  So here's the line, or something so similar that you wouldn't be able to tell the difference:

 

fs.WriteByte(bytes);

 

fs is a file stream, bytes is an array of bytes, and i is the index of a for loop.  Happy now?

 

And the exception is called OutOfMemoryException.  I thought that was a common enough one that pretty much anyone would recognize it.

Share this post


Link to post
Share on other sites
1 minute ago, myvraccount said:

So for future reference, what kinds of things are intended for the beginners forum?

If you visit the For Beginners forum, there is a thread about this.

 

2 minutes ago, myvraccount said:

I don't know why everyone ALWAYS expects me to post code.

Because that's where the errors are.

 

2 minutes ago, myvraccount said:

Happy now?

No. Post a proper question with some decent context or don't waste our time.

Share this post


Link to post
Share on other sites

This topic is 369 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.

Guest
This topic is now closed to further replies.
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!