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. Difference between malloc and LocalAlloc

Difference between malloc and LocalAlloc

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • U Offline
    U Offline
    User 221267
    wrote on last edited by
    #1

    Hi, I will like to know what is the difference between malloc and localalloc? Thanks.

    T 1 Reply Last reply
    0
    • U User 221267

      Hi, I will like to know what is the difference between malloc and localalloc? Thanks.

      T Offline
      T Offline
      Tibor Blazko
      wrote on last edited by
      #2

      look at return values at first (and than at LocalLock/Unlock help) and: The global and local functions supported for porting from 16-bit code, or maintaining source code compatibility with 16-bit Windows. The global and local 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 and the clipboard functions. Windows 95/98/Me: The heap managers are designed for memory blocks smaller than four megabytes. If you expect your memory blocks to be larger than one or two megabytes, you can avoid significant performance degradation by using the VirtualAlloc or VirtualAllocEx function instead.

      U 1 Reply Last reply
      0
      • T Tibor Blazko

        look at return values at first (and than at LocalLock/Unlock help) and: The global and local functions supported for porting from 16-bit code, or maintaining source code compatibility with 16-bit Windows. The global and local 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 and the clipboard functions. Windows 95/98/Me: The heap managers are designed for memory blocks smaller than four megabytes. If you expect your memory blocks to be larger than one or two megabytes, you can avoid significant performance degradation by using the VirtualAlloc or VirtualAllocEx function instead.

        U Offline
        U Offline
        User 221267
        wrote on last edited by
        #3

        Hi, thanks for your reply.:) So do you mean both malloc and LocalAlloc actually allocates memory from the heap? So I guess the main difference is really it's portability then, isn't it?

        T 1 Reply Last reply
        0
        • U User 221267

          Hi, thanks for your reply.:) So do you mean both malloc and LocalAlloc actually allocates memory from the heap? So I guess the main difference is really it's portability then, isn't it?

          T Offline
          T Offline
          Tibor Blazko
          wrote on last edited by
          #4

          easiest is to look into malloc.c directly (in my case \Program Files\Microsoft Visual Studio\VC98\CRT\SRC) you can find HeapAlloc there (#ifdef WINHEAP)

          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