473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

creating a ram drive in csharp

At the moment i am implementing a ghostscript application in c#.

The Dll functions that i can import via dllimport all write to disk
directly.
As i want base64 encode the files, i don't want the slow disk access,
but do all functions in memory.

Could someone tell me if there is a way in which i can create a ram
drive, which i can write to ??

At the moment i am gooling my butt off but can't find anything

TIA

Otto

Jan 25 '07 #1
13 14191
kr********@gmail.com wrote:
Could someone tell me if there is a way in which i can create a ram
drive, which i can write to ??
How about using memory-mapped files instead?

Ebbe
Jan 25 '07 #2
Hello ebbe

I use the following dll import from gsdll32.dll

[DllImport("gsdll32.dll", EntryPoint="gsapi_init_with_args")]
private static extern int gsapi_init_with_args (IntPtr instance, int
argc, IntPtr argv);

As you can see the dll uses a argcounter and argvalues. The values are
filled with the following values:

args[0]="-dNOPAUSE";
args[1]="-dBATCH";
args[2]="-dSAFER";
args[3]="-sDEVICE=pdfwrite";
args[4]="-sOutputFile="+outputFile;
args[5]=inputFile;

both inputfile and outputfile contain a path or unc. there is no
functionality for using any stream type's.
can the memory mapped files be reached by a path.

or are memory mapped files just kind of pointer that i have to pass
from one application to another ???

On 25 jan, 11:28, "Ebbe Kristensen" <e...@ekologic.dkwrote:
krach.a...@gmail.com wrote:
Could someone tell me if there is a way in which i can create a ram
drive, which i can write to ??How about using memory-mapped files instead?

Ebbe
Jan 25 '07 #3
On 25 Jan 2007 02:14:46 -0800, kr********@gmail.com wrote:
>At the moment i am implementing a ghostscript application in c#.

The Dll functions that i can import via dllimport all write to disk
directly.
As i want base64 encode the files, i don't want the slow disk access,
but do all functions in memory.

Could someone tell me if there is a way in which i can create a ram
drive, which i can write to ??

At the moment i am gooling my butt off but can't find anything

TIA

Otto
Do the DLL functions write to a file, or to a file stream? If to a
file stream then you might get the effect that you want by using a
memory stream.

DLL -memoryStream -Base64 -disk

rossum
Jan 25 '07 #4
kr********@gmail.com wrote:
or are memory mapped files just kind of pointer that i have to pass
from one application to another ???
Memory mapped files are loaded into memory but otherwise behave as ordinary
files. Thus you get the speed advantage of having the file in memory without
bothering the OS - and the interface is exactly the same as if you accessed
the file on disk. You may find some more info here:

http://www.catch22.net/tuts/bigmem01.asp

Ebbe
Jan 25 '07 #5
<kr********@gmail.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
Hello ebbe

I use the following dll import from gsdll32.dll

[DllImport("gsdll32.dll", EntryPoint="gsapi_init_with_args")]
private static extern int gsapi_init_with_args (IntPtr instance, int
argc, IntPtr argv);

As you can see the dll uses a argcounter and argvalues. The values are
filled with the following values:

args[0]="-dNOPAUSE";
args[1]="-dBATCH";
args[2]="-dSAFER";
args[3]="-sDEVICE=pdfwrite";
args[4]="-sOutputFile="+outputFile;
args[5]=inputFile;

both inputfile and outputfile contain a path or unc. there is no
functionality for using any stream type's.
can the memory mapped files be reached by a path.
No, they can't.
But this aside why do you want to re-invent the wheel and implement a RAM disk in C#, there
are plenty of RAM disk implementations available in the public domain.

Willy.

Jan 25 '07 #6
Okey, here is a complete drill-down of my scenario :
- Enviroment is a windows 2003 server wunning a windows service.
- Due to company policy i am unable to install any software on the
server.
- I'm looking for a "Microsoft" solution without the use of third party
tools. Again because of company rules.

My windows service works as follows :
- it listens to a websphere MessageQueue from wich it receives a soap
message
- the soap contains base64 Postscript data
- file has to beconverted (this is my tricky part)
- file has to be re-encoded as a base64 string, and sent back as a soap
message

Due to requirements of the conversion only 1 package will do namely
ghostscript (which is currently going through a package acceptation by
the company ict managment)
ghostscript accepts only file paths as parameters. all disk io is done
by the dll that is called.
I want to avoid disk usage as much as possible to gain in speed.
hopefully this gives a better view of my problem (so not only technical
but also policy is in my way).

Jan 25 '07 #7
<kr********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Okey, here is a complete drill-down of my scenario :
- Enviroment is a windows 2003 server wunning a windows service.
- Due to company policy i am unable to install any software on the
server.
- I'm looking for a "Microsoft" solution without the use of third party
tools. Again because of company rules.
A RAM disk consist of a device driver. So, your only option (due to policy) is to develop
such a driver yourself using the WDK (Windows Driver Kit). Wonder whether the company rules
will allow you to install such device driver though.
Not also the only sofisticated drivers will outperform the OS cache manager, most RAM disk
drivers available perform worse than a modern Hard Disk subsystem.

My windows service works as follows :
- it listens to a websphere MessageQueue from wich it receives a soap
message
- the soap contains base64 Postscript data
- file has to beconverted (this is my tricky part)
- file has to be re-encoded as a base64 string, and sent back as a soap
message

Due to requirements of the conversion only 1 package will do namely
ghostscript (which is currently going through a package acceptation by
the company ict managment)
ghostscript accepts only file paths as parameters. all disk io is done
by the dll that is called.
I want to avoid disk usage as much as possible to gain in speed.
I'm not sure whether you will gain anything when using a RAM disk, as said above modern disk
subsystems are quite performant. Anyway, the only way to find out wheter a RAM disk would be
of any help is *measure*, however, as your environment is constrained by company policies, I
don't see how you will be able to accomplish this.
Note also that I doubt you will gain anything at all using A RAM disk, after all, the
slowest link is the network (10-100? times slower than a disk).
Willy.
Jan 25 '07 #8
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uX**************@TK2MSFTNGP03.phx.gbl...
<kr********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
>Okey, here is a complete drill-down of my scenario :
- Enviroment is a windows 2003 server wunning a windows service.
- Due to company policy i am unable to install any software on the
server.
- I'm looking for a "Microsoft" solution without the use of third party
tools. Again because of company rules.

A RAM disk consist of a device driver. So, your only option (due to policy) is to develop
such a driver yourself using the WDK (Windows Driver Kit). Wonder whether the company
rules will allow you to install such device driver though.
Not also the only sofisticated drivers will outperform the OS cache manager, most RAM disk
Sorry above should read:
Note, that only sophisticated ...

Willy.

Jan 25 '07 #9
Thnx for the response willy,

I think i'm just sticking to writing to disk and doing some performance
test there.
Tomorrow i'm doing a stress test and will await the results of that.
If disk performance is low due to huge file size's, i will then fall
back to another scenario.

Maybe an infrastructure solution raid / cache / clustering will provide
the required QOS i want.

I would like to thank everyone in the thread for their comment's.

If i ever find a good solution i will post it here again.

Jan 25 '07 #10
<kr********@gmail.comwrote in message
news:11*********************@v33g2000cwv.googlegro ups.com...
Thnx for the response willy,

I think i'm just sticking to writing to disk and doing some performance
test there.
Tomorrow i'm doing a stress test and will await the results of that.
If disk performance is low due to huge file size's, i will then fall
back to another scenario.
Don't know what you call huge files, but beware that your RAM disk must be at least the size
of your largest file, and this RAM space can't be used for anything else in the system,
there are far better way's to use your available RAM, really.

Maybe an infrastructure solution raid / cache / clustering will provide
the required QOS i want.
I'm don't think that Ghostscript would be able to saturate a single modern disk subsystem.
Anyway, a raid0 configuration with a couple of SATA2 drives will easily outperform a RAM
disk,

Willy.
Jan 25 '07 #11
Jay
"most RAM disk drivers available perform worse than a modern Hard Disk subsystem"

Is that true for mutliple random access to a large file? I would have thought that the seek time of
a hard disk subsystem would seriously slow things down if the file size is considerably larger than
the hard disk cache size. By using a RAM disk, the seek time should be much faster.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uX**************@TK2MSFTNGP03.phx.gbl...
<kr********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
Okey, here is a complete drill-down of my scenario :
- Enviroment is a windows 2003 server wunning a windows service.
- Due to company policy i am unable to install any software on the
server.
- I'm looking for a "Microsoft" solution without the use of third party
tools. Again because of company rules.
A RAM disk consist of a device driver. So, your only option (due to policy) is to develop
such a driver yourself using the WDK (Windows Driver Kit). Wonder whether the company rules
will allow you to install such device driver though.
Not also the only sofisticated drivers will outperform the OS cache manager, most RAM disk
drivers available perform worse than a modern Hard Disk subsystem.

My windows service works as follows :
- it listens to a websphere MessageQueue from wich it receives a soap
message
- the soap contains base64 Postscript data
- file has to beconverted (this is my tricky part)
- file has to be re-encoded as a base64 string, and sent back as a soap
message

Due to requirements of the conversion only 1 package will do namely
ghostscript (which is currently going through a package acceptation by
the company ict managment)
ghostscript accepts only file paths as parameters. all disk io is done
by the dll that is called.
I want to avoid disk usage as much as possible to gain in speed.
I'm not sure whether you will gain anything when using a RAM disk, as said above modern disk
subsystems are quite performant. Anyway, the only way to find out wheter a RAM disk would be
of any help is *measure*, however, as your environment is constrained by company policies, I
don't see how you will be able to accomplish this.
Note also that I doubt you will gain anything at all using A RAM disk, after all, the
slowest link is the network (10-100? times slower than a disk).
Willy.

Jan 26 '07 #12
"Jay" <nospamwrote in message news:OP*************@TK2MSFTNGP06.phx.gbl...
"most RAM disk drivers available perform worse than a modern Hard Disk subsystem"

Is that true for mutliple random access to a large file? I would have thought that the
seek time of
a hard disk subsystem would seriously slow things down if the file size is considerably
larger than
the hard disk cache size. By using a RAM disk, the seek time should be much faster.
True, but the OP is not talking about a desktop but about a server system, modern HD
subsystems (with entry level RAID controllers) with 256MB and more read/write cache are
common. Also on this kind of servers you can't afford to waste say +500MB of precious RAM
for a RAM drive, note that this memory is taken from systems memory normally used as FS
cache, so here you start competing with the systems IO subsystem, probably reducing the
overall system performnce.

Willy.

Jan 26 '07 #13
Jay
Good points Willy, thanks for your comments.
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Jay" <nospamwrote in message news:OP*************@TK2MSFTNGP06.phx.gbl...
"most RAM disk drivers available perform worse than a modern Hard Disk subsystem"

Is that true for mutliple random access to a large file? I would have thought that the
seek time of
a hard disk subsystem would seriously slow things down if the file size is considerably
larger than
the hard disk cache size. By using a RAM disk, the seek time should be much faster.
True, but the OP is not talking about a desktop but about a server system, modern HD
subsystems (with entry level RAID controllers) with 256MB and more read/write cache are
common. Also on this kind of servers you can't afford to waste say +500MB of precious RAM
for a RAM drive, note that this memory is taken from systems memory normally used as FS
cache, so here you start competing with the systems IO subsystem, probably reducing the
overall system performnce.

Willy.
Jan 26 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
1
by: BuddyWork | last post by:
Hello, I need to know how I can check if the drives on my machine are network drives and local drives via the .Net framework. For example my PC has the following drives C: Local D: Local N:...
2
by: Jason Chan | last post by:
how can i know how many drive in computer? Thanks in advance
6
by: Eran Kampf | last post by:
I am trying to dynamically create directories in my ASP.NET application (I am using Server.MapPath("/")+"test" as the folder) and I am getting a DirectoryNotFoundException saying "Could not find a...
4
by: GregT | last post by:
Is there a way to programmatically identify a local CD drive/drives from a local machine. Currently, I am calling System.IO.Directory.GetLogicalDrives() - but this lists all the drives on the...
1
by: barbara_dave | last post by:
Hi all, I use GetLogicDrive to get all drives. when I use "for each.." loop searching each drive, I got error"A: drive not ready",... I want to seach some files which are in a drive, but I don't...
4
by: CodeLeon | last post by:
I read in the...
0
by: =?Utf-8?B?TGlhbSBNYWM=?= | last post by:
Hi Folks, I have embeded WMI scripting within a Visual Basic application to create remote shares and set permissions, I'm now moving to vb.net environment and having trouble getting my scripting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.