How can I get memory allocated on PHYSICAL RAM and garanteed not on virtual ram.

  • Thread starter Thread starter FU.U.NA
  • Start date Start date
F

FU.U.NA

Hi.

I simply want to allocate large size of memory (about 300~400 MB) on
just physical RAM (not on disc virtual ram).
I'm finding the garanteed method of allocating memory on PHYSICAL RAM.



DECRIPTION OF MY SITUATION:

I'm testing file copying with large memory cache.
As I know, disc reading and writing shows better performance when do
that at once. (sequal reading & writing)
And I think Windows Explorer copy routine does not use all memory that
they can use.
So I want to make my own routine that copying large file with large
cache.
(I have many large files have to be copied often between drives.)

To do that, I need large and fast speed cache to copy large byte
chunks.
And the cache never be on the virtual ram.

I don't know well about low level working of .NET FW and windows API.
So I want to find garanteed method of allocating memory on PHYSICAL
RAM.

Or, if you know about better way about fast copying of large file,
that's good also.




PS:
This is just test and private work, not a business job. Please don't
discuss about efficiency.
 
You are confused here. You want performance but you want to use the disk? In
addition, unless you are doing pretty low level stuff, RAM management is
outside of your control. The operating system is still free to swap out your
cached files to disk depending on resource pressure negating your efforts.
Unless you have deep experience, managing operating system resources should
not be your responsibility. I suggest you revisit your architecture so that
you have a better understanding of the process. If you feel you have a solid
understanding, you will have to use the win32 api thru managed as a solution
to your problem.
 
I think you misunderstood my posting. And it caused by my mistake.
My plan was only making a program that copies large files from drive
into other drive as fast as possible.
The 'memory' I said was the 'buffer'.

This is code sample;

Stream srcFile sf = new FileStream ( ... );
Stream trgFile tf = new FileStream ( ... );

// 128 MB buffer. Very big buffer. This can consume all memory.
// But this always have to be placed on physical ram.
// Is there no managed way make this only on physical ram?
// or the wat to get current available physical ram size?
byte[] buffer = new byte [ 1024 * 1024 * 128 ];

// Read 128 MB at once.
int readCount = sf.Read ( buffer, 0, buffer.length );

// And write 128 MB at once.
tf.Write ( buffer, 0, readCount );


I understand you said as 'there is no managed way (excludes interop)
to get the garantee and you have to use WIN32 API to do that'.













Alvin Bruney said:
You are confused here. You want performance but you want to use the disk? In
addition, unless you are doing pretty low level stuff, RAM management is
outside of your control. The operating system is still free to swap out your
cached files to disk depending on resource pressure negating your efforts.
Unless you have deep experience, managing operating system resources should
not be your responsibility. I suggest you revisit your architecture so that
you have a better understanding of the process. If you feel you have a solid
understanding, you will have to use the win32 api thru managed as a solution
to your problem.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
FU.U.NA said:
Hi.

I simply want to allocate large size of memory (about 300~400 MB) on
just physical RAM (not on disc virtual ram).
I'm finding the garanteed method of allocating memory on PHYSICAL RAM.



DECRIPTION OF MY SITUATION:

I'm testing file copying with large memory cache.
As I know, disc reading and writing shows better performance when do
that at once. (sequal reading & writing)
And I think Windows Explorer copy routine does not use all memory that
they can use.
So I want to make my own routine that copying large file with large
cache.
(I have many large files have to be copied often between drives.)

To do that, I need large and fast speed cache to copy large byte
chunks.
And the cache never be on the virtual ram.

I don't know well about low level working of .NET FW and windows API.
So I want to find garanteed method of allocating memory on PHYSICAL
RAM.

Or, if you know about better way about fast copying of large file,
that's good also.




PS:
This is just test and private work, not a business job. Please don't
discuss about efficiency.
 
Have you considered using a RAM disk to facilitate the copy? i don't have a lot of experience with copying files quickly, but if you want to be sure to get physical memory, creating a RAM disk is one way to make sure you get it. Otherwise I guess you could just turn down your virtual memory settings in Windows, but that would probably case MORE swapping of other applications and data.
 
Back
Top