data from a file instead of memory

This is a discussion on data from a file instead of memory within the Windows Programming forums, part of the Platform Specific Boards category; I am sure there is a simple answer to this, but I sure can't find it. I have found myself ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    170

    data from a file instead of memory

    I am sure there is a simple answer to this, but I sure can't find it. I have found myself practicly writing a database, but its all in memory.

    I am using MSVC 6 MFC template class CMap. It works great, does what I need and its fast. However, my dataset is large, say 20MB or so and I don't want to clog up the memory.

    I store the data on disk, but when I serialize in my CMap it sucks the whole file into memory.

    Is there a way to get the benefits of CMap functionality with the data being accessed directly from the file?
    Best Regards,

    Bonkey

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Look up on MSDN for Memory Mapped Files.....

    File Mapping Functions
    The following functions are used with file mapping.



    CreateFileMapping
    FlushViewOfFile
    MapViewOfFile
    MapViewOfFileEx
    MapViewOfFileVlm
    OpenFileMapping
    UnmapViewOfFile
    UnmapViewOfFileVlm
    With them you can create a map of a peart of a big file, work on it, close the mapping (dont get confused withthe map you are using as a data struct ) and that segment will be saved to disk

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    170

    Thumbs up

    Thanks. That looks like it may do the trick. I'll let you know.
    Best Regards,

    Bonkey

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    170

    Thumbs up

    Thanks for the info, but I found a different way to go. Use a database file without a database.

    http://www.codeguru.com/mfc_database/daoarticle.html
    Best Regards,

    Bonkey

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    File-mapping is a good solution for most I/O, especially when working with large file size.

    Kuphryn

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789

    Thumbs up

    That's a good link

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 01:44 PM
  2. Replies: 48
    Last Post: 09-26-2008, 04:45 AM
  3. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 02:41 PM
  4. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21