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. Global memory (GlobalAlloc, etc...)

Global memory (GlobalAlloc, etc...)

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
4 Posts 3 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.
  • D Offline
    D Offline
    Dominik Reichl
    wrote on last edited by
    #1

    Hello, is the memory allocated by the GlobalAlloc function really global? Can different processes access the same memory block allocated by GlobalAlloc? Thanks -Dominik

    S 1 Reply Last reply
    0
    • D Dominik Reichl

      Hello, is the memory allocated by the GlobalAlloc function really global? Can different processes access the same memory block allocated by GlobalAlloc? Thanks -Dominik

      S Offline
      S Offline
      Sigmund
      wrote on last edited by
      #2

      No. Memory allocated by GlobalAlloc is not visible to other process. If you want to share memory across process, i sugest that you use memory mapped files. Also, MSDN state that GlobalAlloc is not the preferred way to allocate memory. Try the heap memory function instead (HeapAlloc, HeapFree, ect,ect).

      D 1 Reply Last reply
      0
      • S Sigmund

        No. Memory allocated by GlobalAlloc is not visible to other process. If you want to share memory across process, i sugest that you use memory mapped files. Also, MSDN state that GlobalAlloc is not the preferred way to allocate memory. Try the heap memory function instead (HeapAlloc, HeapFree, ect,ect).

        D Offline
        D Offline
        Dominik Reichl
        wrote on last edited by
        #3

        Ok, I will use memory mapped files. Thank you! -Dominik

        J 1 Reply Last reply
        0
        • D Dominik Reichl

          Ok, I will use memory mapped files. Thank you! -Dominik

          J Offline
          J Offline
          Joe Woodbury
          wrote on last edited by
          #4

          When you call ::CreateFileMapping with (HANDLE) LongToHandle(-1) as the first parameter, PAGE_READWRITE as the protection and a name, which is how other applications will access it by calling OpenFileMapping. If the creator will be in one set of permissions (like a service logged in as an administrator) and the other application will have lower permissions, you'll need to create and use SECURITY_ATTRIBUTES (you can create a NULL security attribute which essentially grants global rights to the memory.)

          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