Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Reading 4 GB file using 2 GB physical memory [modified]

Reading 4 GB file using 2 GB physical memory [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
performancehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adam Roderick J
    wrote on last edited by
    #1

    hi guys, i came up with a problem. I have 4 GB file(disk size) and i want to read this file in my 2 GB(primary memory) machine. Please suggest the best method to do so?

    Величие не Бога может быть недооценена.

    modified on Tuesday, December 21, 2010 2:57 AM

    L 1 Reply Last reply
    0
    • A Adam Roderick J

      hi guys, i came up with a problem. I have 4 GB file(disk size) and i want to read this file in my 2 GB(primary memory) machine. Please suggest the best method to do so?

      Величие не Бога может быть недооценена.

      modified on Tuesday, December 21, 2010 2:57 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can always read data in chunks. Do you mean how to load the entire 4GB into RAM?

      ...byte till it megahertz... my donation to web rubbish

      A 1 Reply Last reply
      0
      • L Lost User

        You can always read data in chunks. Do you mean how to load the entire 4GB into RAM?

        ...byte till it megahertz... my donation to web rubbish

        A Offline
        A Offline
        Adam Roderick J
        wrote on last edited by
        #3

        Not exactly, i want to find some data in that file. So need to until that point is enough, but that search may be on last part. So i need a mechanism to do so. I believe CreateFileMapping can be used, do u think, its a good solution?

        Величие не Бога может быть недооценена.

        L 1 Reply Last reply
        0
        • A Adam Roderick J

          Not exactly, i want to find some data in that file. So need to until that point is enough, but that search may be on last part. So i need a mechanism to do so. I believe CreateFileMapping can be used, do u think, its a good solution?

          Величие не Бога может быть недооценена.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          So you indeed need to read data in chunks as I said. Load a chunk and perform the search. Keep loading the next part of the file into the chunk until you get the data. To do this, you may use memory mapped file or one of the various read(...) functions (Win32 API, CRT etc). Either way, you would still have to read the file in chunks.

          ...byte till it megahertz... my donation to web rubbish

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups