c++ - Memory Mapped FIle is slow -


i trying read memory mapped file, access file taking long time. mapping whole file program, , initial access fast, begins drastically slow down

the file ~47gb , have 16gb of ram. running 64-bit application on windows 7 using visual studios ide. below snippet of code

    hfile = createfile( "valid path file",                // name of write                         generic_read , // open reading                         0,                      // not share                         null,                   // default security                         open_existing,             // existing file                         file_attribute_normal,  // normal file                         null);                  // no attr. template      if (hfile == invalid_handle_value)     {         cout << "unable open vals" << endl;         exit(1);     }      hmapfile = createfilemapping(                                 hfile,                                               null,                        // default security                                 page_readonly,      // read/write access                                 0,                           // maximum object size (high-order dword)                                 0,                           // maximum object size (low-order dword)                                 null);                       // name of mapping object      if (hmapfile == null)     {         cout<< "error code " << getlasterror() << endl;         exit(1);     }         data = (float*) mapviewoffile(                             hmapfile,                             file_map_read,                             0,                             0,                             0);      if (data == null)     {         cout << "error code " << getlasterror() << endl;          closehandle(hfile);          exit(1);     } 

is because file large continually swapping chunks of file takes long, or other parameter need faster access?

edit: tried using read instead of using read, write, execute seen above, speed still slow. understand concepts of memory mapping , switch swap space, thought may have been doing else wrong hindering speed

this because of paging. happening ram can hold 16gb of file (in reality less because of other programs running on computer, let's use simplicity).

so if access part of file in program not in ram (let's say, part of file in 20gb segment) ram needs talk disk , transfer whole new segment of file ram. takes lot of time.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -