Jader Dias
Jader Dias

Reputation: 90475

Can I create a virtual disk in memory programatically?

For performance purposes I want to write to memory, where an external application can read. I can't link both applications together, so I think the only way is by writing a file. But writing it to a physical disk isn't fast enough. I want to mount a virtual partition so any application can access it. How to do it?

Upvotes: 3

Views: 4321

Answers (4)

Chansik Im
Chansik Im

Reputation: 1493

I wish you can use .NET 4.0 :)

.NET 4.0 introduces memory mapped file.

Gunnar Peipman blogged nicely in the following link: .Net Framework 4.0: Using memory mapped files

In his blog, "Memory mapped files are useful when you need to do in-memory data manipulation and your data structures are large. For large in-memory data the performance of memory mapped file is the best. It is much faster than MemoryStream. And like files on hard disc, memory mapped files can be shared between different programs."

His blog also contains the sample code as well.

Upvotes: 1

RichieHindle
RichieHindle

Reputation: 281515

You don't need to go as far as creating a virtual disk to share memory between processes on Windows - you can create a shared memory block, and multiple processes can then access that memory.

See this MSDN article: Creating Named Shared Memory

Upvotes: 9

dar7yl
dar7yl

Reputation: 3747

You could use a named pipe to transfer the data between applications.

Upvotes: 3

Nifle
Nifle

Reputation: 11933

I have seen some commersial avaliable ramdisk implementation for .net but I cant seem to find it right now.

Another option might be: C# accessing memory map file

Upvotes: 1

Related Questions