home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / os2 / programm / 8013 < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.9 KB  |  43 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!well!shiva
  3. From: shiva@well.sf.ca.us (Kenneth Porter)
  4. Subject: Re: MALLOC() Problems In PM Apps
  5. Message-ID: <C1FIzK.JDt@well.sf.ca.us>
  6. Sender: news@well.sf.ca.us
  7. Organization: Whole Earth 'Lectronic Link
  8. References: <1993Jan13.115314.1082@beckman.com> <1993Jan13.173450.1084@beckman.com>
  9. Date: Mon, 25 Jan 1993 21:42:56 GMT
  10. Lines: 31
  11.  
  12.  
  13. In article <1993Jan13.173450.1084@beckman.com>, rariedel@beckman.com (Bob Riedel) writes:
  14. > In article <1993Jan13.115314.1082@beckman.com>, rariedel@beckman.com (Bob Riedel) writes:
  15. >> Is there a problem with using the malloc() family in a PM app? I keep getting
  16. >> segment violations in something called searchseg() inside malloc() when I
  17. >> (or _beginthread) use this call.
  18. >> 
  19. >> Does this mean I have to use the Window heap manager calls instead of malloc()?
  20. >> 
  21. >> If so... that sucks!
  22. > I did not mention that I am trying to build an APP using GPF for OS/2 V1.3
  23. > using the Microsoft C6.0 compiler.
  24.  
  25. I've also seen this behaviour. I traced the lockup into
  26. DosReallocSeg, which is called when malloc needs to grow the heap
  27. segment to allocate more memory.  My solution was to set the global
  28. malloc variable _amblksiz (defined in malloc.h) to a value close to
  29. 64k. This variable specifies the size of the DosAllocSeg allocation
  30. that malloc will initially make. When it uses up this amount, malloc
  31. must call DosReallocSeg to grow the segment, or if it's at maximum
  32. size, call DosAllocSeg to start a new one.  This forces malloc to
  33. always make initial segment allocations the maximum size, thus never
  34. calling DosReallocSeg.
  35.  
  36. You can see that that's why malloc works for awhile, then croaks. It
  37. keeps allocating from the initial segment (I think it defaults to
  38. 8k), and when it runs out and calls DosReallocSeg, wham!
  39.  
  40. I sure wish I knew what was really going on, though. I think the MS
  41. runtime is somehow corrupting the OS.
  42.