Announcement

Collapse
No announcement yet.

GlobalMem vs HeapAlloc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GlobalMem vs HeapAlloc

    Dear,

    Could one enlighten me on the pro's and con's over using either memory management technique. Especially the fact that they are now built in
    into the new compilers makes using the GlobalMem functions more attractive
    than the win32 api Heap functions.

    I have been using Heap functions since I encountered the Linked list functions from Don Dickinson and later Paul Squires but I guess replacing them with the GlobalMem wouldn't harm ?

    Cheers

    Steven
    So here we are, this is the end.
    But all that dies, is born again.
    - From The Ashes (In This Moment)

  • #2
    The GLOBAL MEM functions are PB-proprietary, so we can't compare them against fully-documented methods such as HeapAlloc or GlobalAlloc.

    I 'suspect' the GLOBAL MEM functions are currently implemented by the compiler using the GLobalAlloc family of functions. But you never really know.

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      So then, I have to address this question to the engineers of PB to give
      a pro and con's perspective of the GlobalMem functions vs Heap functions

      The audience is listening
      So here we are, this is the end.
      But all that dies, is born again.
      - From The Ashes (In This Moment)

      Comment


      • #4
        If you mean GlobalAlloc vs. HeapAlloc, then underneath they both seem very similar, perhaps only MSDN will document the differences.

        One thing is that handle-based memory (GlobalAlloc with GHND flag) is more efficient as Windows will move around the handle-based memory blocks, whereas GPTR will allocated a fixed block and you process' memory will eventually become fragmented, possibly causing "out of memory" or swap file usage. The best method is to allocate memory using handles and lock it (GlobalLock) where needed.
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          FWIW:
          The GlobalAlloc function allocates the specified number of bytes from the heap. Windows memory management does not provide a separate local heap and global heap.

          Note The global functions are slower than other memory management functions and do not provide as many features. Therefore, new applications should use the heap functions. However, the global functions are still used with DDE, the clipboard functions, and OLE data objects.
          I think there is also some doc re the Global functions being optimized for blocks of 4 Mb or less but I can't find that anywhere this AM.

          Depending on the application (conveniently not described), it's probably moot from a techical perspective and your choice of methods should be based more on maintainability than anything else.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X