home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / os / mswindo / programm / misc / 3410 < prev    next >
Encoding:
Internet Message Format  |  1992-11-07  |  2.9 KB

  1. Xref: sparky comp.os.ms-windows.programmer.misc:3410 comp.os.ms-windows.programmer.tools:1413
  2. Newsgroups: comp.os.ms-windows.programmer.misc,comp.windows.ms.programmer,comp.os.ms-windows.programmer.tools
  3. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sdd.hp.com!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!cs.ubc.ca!uw-beaver!fluke!moriarty
  4. From: moriarty@tc.fluke.COM (Jeff Meyer)
  5. Subject: Re: generic replacement for malloc and free using Global...?
  6. Message-ID: <1992Nov13.182636.5749@tc.fluke.COM>
  7. Followup-To: comp.os.ms-windows.programmer.misc
  8. Summary: MS, w/ C7 and Win 3.1, recommends going back to using malloc
  9. Keywords: malloc free GlobalAlloc GlobalFree
  10. Reply-To: moriarty@tc.fluke.COM (Jeff Meyer)
  11. Organization: The John Fluke Mfg. Co.  /a.k.a. The Gizmonics Institute/
  12. Date: Fri, 13 Nov 1992 18:26:36 GMT
  13. Lines: 40
  14.  
  15. In comp.windows.ms.tools whedon@netcom.com writes:
  16.  
  17. >I wonder if anyone has a generic replacement for malloc and free which make
  18. >use of GlobalAlloc and GlobalFree?  I did those up, but for some reason, the
  19. >memory thus allocated doesn't seem to be getting released properly, even
  20. >though I am careful to execute one free for each malloc.  As an offshoot of
  21. >this, my memory slowly goes down in Windows until I terminate my app, at
  22. >which time it all appears to come back. Any ideas?  Working procs?   Please
  23. >email me and I will summarize, as I know of at least two other people who
  24. >want this stuff.  I suspect there're more...
  25.  
  26. There's a Microsoft C/C++ Technical Note ("Allocating Memory the
  27. Old-Fashioned Way: _fmalloc and Applications for Windows" by Dale Rogerson,
  28. dated July of this year) that basically says that with the combination of MS
  29. C/C++ 7.0 being released and the advent of Windows 3.1 (where there is no
  30. real mode) -- and, I suspect, the coming of Win32 and NT -- MS is going back
  31. to recommending that you use malloc and free instead of the
  32. LocalAlloc/GlobalAlloc calls.
  33.  
  34. In particular, the article mentions using _fmalloc (under C7, calls to
  35. malloc in large memory models are automatically mapped to _fmalloc) as
  36. opposed to GlobalAlloc because it is more efficient in the use of memory;
  37. fmalloc basically calls GlobalAlloc with the GMEM_MOVEABLE option, but
  38. doesn't allocate a new global segment for each call for memory.
  39. Using _ffree, however, appears to be a bit more complex than using
  40. GlobalFree; see the article for more information.
  41.  
  42. Don't know if this is of help, but I thought I should draw your attention to
  43. this article.  (After using Global/LocalAlloc for months, it sort of took me
  44. by surprise that MS was suggesting going back to malloc!)
  45.  
  46.                            "Open Channel D..."
  47. ---
  48.                                         Moriarty, aka Jeff Meyer
  49. INTERNET:     moriarty@tc.fluke.COM
  50. Manual UUCP:  {uunet, uw-beaver, sun, microsoft}!fluke!moriarty
  51. CREDO:        You gotta be Cruel to be Kind...
  52.                  **>> Keep circulating the tapes <<**
  53.  
  54.  
  55.