Jump to content
  • Advertisement
Sign in to follow this  
Mari_p

Doubts regarding RAM and HD when working with files

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

Hi, I have some doubts regarding the allocated memory space when working with files. Suppose I have a huge file (>1GB) in my HD. When I open this file by using the fopen function, I get a pointer to the FILE struct... and I think a very small RAM space is allocated, independently of the file's size (is this correct?). On the other hand, when I use the fseek function to set the indicator's position 'inside' a file, in true I'm working on RAM. Please, could anybody explain me this relation between RAM and HD when using the fseek function? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
When you open a file a small buffer, typically 4K, is allocated. Even when you fseek, you don't use any more memory than the original buffer size.

Share this post


Link to post
Share on other sites
Quote:
Original post by LessBread
RAM and HD meet in the form of Virtual memory. If you're running Windows and you want to learn more about working with very large files, check out these tutorials: Memory Management for Large-File Editors - Part 1, Memory Management for Large-File Editors - Part 2.


Part 2 which talks about "Span Tables" is pretty close to what I do with my large file editor. I added an extra optimization when coming up with my system - I have a large buffer (64K) that is not a memory mapped section of the file. When I seek in the file, I refresh the large buffer - each refresh loops through the span table and modifies the large buffer. From then on, I can seek in that 64K window with no Span traversal whatsoever.

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!