-
Allocate disc space
Ok, here is the problem, I want to try running functions on large files to see how long the will take to run, but I don't want to make huge text files and run the functions against them. Is there a way to allocate memory, let's say 100mb and then run a function on those bytes/bits? (the content doesn't matter)
-
Re: Allocate disc space
It would not be an acurate test, If you need to check the speed of processing large files then you should work with large files. Memory is much faster that file i/o
Surely you have some large files already on the system
-
Re: Allocate disc space
DataMiser is correct. However, should you still want to pursue this, you may find MemoryStream (link) to be useful. In short, it is a Stream (like a filestream) that is backed by a byte array.
Hope that helps!
-
Re: Allocate disc space
With the respect to DataMiser's point, I've used following unmanaged methods to (de)allocate large amout of memory
Code:
IntPtr p = Marshal.AllocHGlobal(size);
Marshal.FreeHGlobal(p);