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. file share problem

file share problem

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
16 Posts 6 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.
  • Y york528

    I forgot. It means to share a big file between multi-process so all the processes can read the file Thank you!~

    _ Offline
    _ Offline
    _Superman_
    wrote on last edited by
    #5

    You could use CreateFile[^] with FILE_SHARE_READ|FILE_SHARE_WRITE as its share mode parameter.

    «_Superman_» I love work. It gives me something to do between weekends.

    Y 1 Reply Last reply
    0
    • _ _Superman_

      You could use CreateFile[^] with FILE_SHARE_READ|FILE_SHARE_WRITE as its share mode parameter.

      «_Superman_» I love work. It gives me something to do between weekends.

      Y Offline
      Y Offline
      york528
      wrote on last edited by
      #6

      not that problem when I create a file mapping that the file is bigger than 1.5Gb the CreateFileMapping return ERROR_NOT_ENOUGH_MEMORY And I was wondering if I can map a big file (3-4G) to share in one time that's what I want for example I have a 3G file and 100 people wanna read it so I wanna share it that's the situation Thank you !~

      _ 1 Reply Last reply
      0
      • L Lost User

        I would recommend reading the Microsoft article Creating a File Mapping Object[^] Specifically the 'File Mapping Size' section where it states the following: The size of a file mapping object that is backed by a named file is limited by disk space. The size of a file view is limited to the largest available contiguous block of unreserved virtual memory. This is at most 2 GB minus the virtual memory already reserved by the process. Best Wishes, -David Delaune

        Y Offline
        Y Offline
        york528
        wrote on last edited by
        #7

        Thank you so much I read the book Programming Applications for Microsoft Windows by Jeffrey Richter but biside file mapping Is there another way to share a big file in one time I always wanna find a better way :)

        L 1 Reply Last reply
        0
        • Y york528

          Thank you so much I read the book Programming Applications for Microsoft Windows by Jeffrey Richter but biside file mapping Is there another way to share a big file in one time I always wanna find a better way :)

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

          I think you should re-evaluate your application requirements. Do you *really* need to share 3 Gigabytes of a file between multiple processes? Why not share small sections of the file as needed? Have a look at the sample: Creating a View Within a File[^] You could use a similar technique and share 250 megabytes or more of the file at a time. Best Wishes, -David Delaune

          Y S 2 Replies Last reply
          0
          • L Lost User

            I think you should re-evaluate your application requirements. Do you *really* need to share 3 Gigabytes of a file between multiple processes? Why not share small sections of the file as needed? Have a look at the sample: Creating a View Within a File[^] You could use a similar technique and share 250 megabytes or more of the file at a time. Best Wishes, -David Delaune

            Y Offline
            Y Offline
            york528
            wrote on last edited by
            #9

            Thank you I'll try that :-D :thumbsup:

            S 1 Reply Last reply
            0
            • Y york528

              not that problem when I create a file mapping that the file is bigger than 1.5Gb the CreateFileMapping return ERROR_NOT_ENOUGH_MEMORY And I was wondering if I can map a big file (3-4G) to share in one time that's what I want for example I have a 3G file and 100 people wanna read it so I wanna share it that's the situation Thank you !~

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #10

              Instead of mapping the file to memory, all 100 people can read it from disk using CreateFile and the share flags.

              «_Superman_» I love work. It gives me something to do between weekends.

              Y 1 Reply Last reply
              0
              • L Lost User

                I think you should re-evaluate your application requirements. Do you *really* need to share 3 Gigabytes of a file between multiple processes? Why not share small sections of the file as needed? Have a look at the sample: Creating a View Within a File[^] You could use a similar technique and share 250 megabytes or more of the file at a time. Best Wishes, -David Delaune

                S Offline
                S Offline
                SelvaKr
                wrote on last edited by
                #11

                Just by going thru the link, i understood that, it talks about memory mapping files. But i think process address space is limited to 4GB in 32 bit windows. (2GB-Process; 2GB-Kernel) Hence if you need 3GB of space at a point from your application, you maynot be able to address it. Check for /3GB switch (even though it is not advisable)... which may give you some more information to approach your problem... As Randor pointed, u may have to unmap and map whenever required.

                Selva

                Y 1 Reply Last reply
                0
                • _ _Superman_

                  Instead of mapping the file to memory, all 100 people can read it from disk using CreateFile and the share flags.

                  «_Superman_» I love work. It gives me something to do between weekends.

                  Y Offline
                  Y Offline
                  york528
                  wrote on last edited by
                  #12

                  speed is important IO is slower than file mapping that's why I wanna use it Best Wishes One day I will get what I wish by working hard

                  1 Reply Last reply
                  0
                  • S SelvaKr

                    Just by going thru the link, i understood that, it talks about memory mapping files. But i think process address space is limited to 4GB in 32 bit windows. (2GB-Process; 2GB-Kernel) Hence if you need 3GB of space at a point from your application, you maynot be able to address it. Check for /3GB switch (even though it is not advisable)... which may give you some more information to approach your problem... As Randor pointed, u may have to unmap and map whenever required.

                    Selva

                    Y Offline
                    Y Offline
                    york528
                    wrote on last edited by
                    #13

                    Thank you for reply I care more about speed Only one server almost 3GB index file is to be read by lots of people you know No matter how a program is perfect, slow speed still can't be acceptable Randor's idea is good I don't know the efficiency in this way

                    1 Reply Last reply
                    0
                    • Y york528

                      I just wanna know how to share a big file, 3-4G when using FileMapping, I only can share a file that not bigger than 1.5G if bigger than that, I got an error of ERROR_NOT_ENOUGH_MEMORY Thanks!

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

                      Hope you are using Win32 API for this purpose. Windows 32 can maximum support 2xy32(2147483648 bytes) at maximum of 4 GB(2 GB maximum), but practically it is difficult to use the maximun of 2 GB so based on the RAM size and other resources, it varies below 2 GB. So i dont think it will possible in Win 32 to load more than 2 GB with the default /2 G, to support more than 2 GB use the switch of /G as mentioned below, http://technet.microsoft.com/en-us/library/bb124810(EXCHG.65).aspx[^]. :) But such design is not good, either read directly from file as mentioned by randor or enable /3G but none of these are fast. Best is need to have maximum physical memory. :) http://www.padtinc.com/epubs/focus/common/focus.asp?I=34&P=article2.htm[^]

                      modified on Tuesday, July 21, 2009 4:50 AM

                      Y 1 Reply Last reply
                      0
                      • Y york528

                        Thank you I'll try that :-D :thumbsup:

                        S Offline
                        S Offline
                        Stuart Dootson
                        wrote on last edited by
                        #15

                        I'll second Randor's suggestion - I've used that technique on files about 1GB in size. I actually wrapped the whole mapping thing in a set of custom STL-style iterators that mapped bits of the file in and out on demand. I've got a half-written article on the subject - I'll have to pull my finger out and finish it :-)

                        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                        1 Reply Last reply
                        0
                        • A Adam Roderick J

                          Hope you are using Win32 API for this purpose. Windows 32 can maximum support 2xy32(2147483648 bytes) at maximum of 4 GB(2 GB maximum), but practically it is difficult to use the maximun of 2 GB so based on the RAM size and other resources, it varies below 2 GB. So i dont think it will possible in Win 32 to load more than 2 GB with the default /2 G, to support more than 2 GB use the switch of /G as mentioned below, http://technet.microsoft.com/en-us/library/bb124810(EXCHG.65).aspx[^]. :) But such design is not good, either read directly from file as mentioned by randor or enable /3G but none of these are fast. Best is need to have maximum physical memory. :) http://www.padtinc.com/epubs/focus/common/focus.asp?I=34&P=article2.htm[^]

                          modified on Tuesday, July 21, 2009 4:50 AM

                          Y Offline
                          Y Offline
                          york528
                          wrote on last edited by
                          #16

                          Thank you!~~~ :laugh: I'll think about it and consider Randor's idea

                          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