Home All Groups Group Topic Archive Search About

FileStream & MapViewOfFile comparison

Author
30 Jun 2006 3:47 PM
Lloyd Dupont
I need to access big data in a readonly fashion.
I was thinking to open a FileStream and seek and read as needed.
I was wondering if it was worth doing my own FileStream class which would
use internally use MapViewOfFile internally?
Or pehaps a purely managed wrapper which, at least, load the bytes in 4k
memory buffer (and update the buffer everytime I move)?

Author
30 Jun 2006 5:25 PM
Mattias Sjögren
Lloyd,

>I was wondering if it was worth doing my own FileStream class which would
>use internally use MapViewOfFile internally?

Have you seen the UnmanagedMemoryStream class in .NET 2.0? It may save
you some work.

There's also a file map helper class available here
http://www.winterdom.com/dev/dotnet/index.html


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
1 Jul 2006 3:07 AM
Lloyd Dupont
interesting link!

Show quote
"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:eTWeQpGnGHA.4208@TK2MSFTNGP04.phx.gbl...
> Lloyd,
>
>>I was wondering if it was worth doing my own FileStream class which would
>>use internally use MapViewOfFile internally?
>
> Have you seen the UnmanagedMemoryStream class in .NET 2.0? It may save
> you some work.
>
> There's also a file map helper class available here
> http://www.winterdom.com/dev/dotnet/index.html
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP]  mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
Author
30 Jun 2006 8:34 PM
Carl Daniel [VC++ MVP]
"Lloyd Dupont" <net.galador@ld> wrote in message
news:u8jL1xFnGHA.3640@TK2MSFTNGP02.phx.gbl...
>I need to access big data in a readonly fashion.
> I was thinking to open a FileStream and seek and read as needed.
> I was wondering if it was worth doing my own FileStream class which would
> use internally use MapViewOfFile internally?

Most likely, no.  The file system already does read-ahead buffering and
generally will do a better job of managing the memory than you can do in
your application.  Unless your needs are very unusual, it's best to just use
the OS-supplied file buffering - which FileStream will use since it's just a
simple wrapper over the Win32 file I/O operations.

-cd
Author
1 Jul 2006 3:08 AM
Lloyd Dupont
thanks!
Show quote
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:OX$%23yQInGHA.4604@TK2MSFTNGP02.phx.gbl...
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:u8jL1xFnGHA.3640@TK2MSFTNGP02.phx.gbl...
>>I need to access big data in a readonly fashion.
>> I was thinking to open a FileStream and seek and read as needed.
>> I was wondering if it was worth doing my own FileStream class which would
>> use internally use MapViewOfFile internally?
>
> Most likely, no.  The file system already does read-ahead buffering and
> generally will do a better job of managing the memory than you can do in
> your application.  Unless your needs are very unusual, it's best to just
> use the OS-supplied file buffering - which FileStream will use since it's
> just a simple wrapper over the Win32 file I/O operations.
>
> -cd
>
>
>
>

AddThis Social Bookmark Button