Wednesday 15 February 2012

c# - Is there anyway to determine how much more ram my prog can allocate till OutOfMemoryException? -


I need to decide if I can fully load the file in the file. Readablebates (fast) or file with process file FileStream, by reading out the amount of bytes close to OutOfMemoryException, but enough to avoid it.

I do this to reduce the HDD load. I think it is better to read 1GB at a time, like chakra likes to read: Read 4 bytes - & gt; Process them - & gt; Read 4 bytes again - & gt; Process them - & gt; ...

"post-text" itemprop = "text">

Memory allocation depends on how much load they currently have. You can not choose a number and hope that you will always be able to allocate that space. You should choose a safe number that is less chance of failure. Currents typically use 1-8MB buffers.

When reading 1 GB and reading 4 times in 256 MB pieces, HDD load will be more or less. Finally: You are reading 1 GB.

No comments:

Post a Comment