home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / misc / 4247 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  2.3 KB

  1. Path: sparky!uunet!lax.pe-nelson.com!lax!twbrown
  2. From: twbrown@PE-Nelson.COM (Tom W. Brown)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: Re: Borland and Memory
  5. Message-ID: <712@lax.lax.pe-nelson.com>
  6. Date: 15 Dec 92 17:37:17 GMT
  7. References: <1gilfkINNjmd@crcnis1.unl.edu> <BzA2sp.199@newsserver.technet.sg> <BzAyI5.BrH@world.std.com> <1992Dec15.144205.16197@mksol.dseg.ti.com>
  8. Sender: news@lax.pe-nelson.com
  9. Distribution: usa
  10. Organization: PE-Nelson
  11. Lines: 41
  12.  
  13. In article <1992Dec15.144205.16197@mksol.dseg.ti.com>, duitz@mksol.dseg.ti.com (mitchel n duitz) writes:
  14. |> I seem to have a point in my code, where I am stuck.
  15. |> 
  16. |> I do a lot of new and delete inside my code, and first,
  17. |> I do see a memory leak somewhere, but I can;t pin it down.
  18. |> 
  19. |> The problem I have is that the program just spins.  This
  20. |> can happen in two different places - either when I declare ofstream ofs(name),
  21. |> or when I'm in a loop allocating a 2 dimensional array - similar to the
  22. |> following
  23. |> 
  24. |> float **kalamazoo
  25. |> 
  26. |> kalamazoo = new float *[150];
  27. |> for(i=0;i<150;i++)
  28. |>    kalamzoo[i]=new float[30];
  29. |> 
  30. |> It seems to just hang inside this loop.
  31. |> PLEASE HELP - ANY AND ALL HELP APPRECIATED.
  32. |> mitch
  33.  
  34. Try using large model (if you're not already).  Based on some investigation
  35. on a discussion over in comp.os.ms-windows.programmer.tools I've seen this
  36. behavior when attempting to allocate (malloc) memory in medium model.
  37.  
  38. I've not confirmed it, but I believe Borland's malloc/free may have problems
  39. when in Windows, but their farmalloc/farfree don't.  The C++ operator new
  40. and delete use the appropriate malloc package for their implementation (or
  41. they both share some underlying internal routines).
  42.  
  43. Note, also, that the above loop allocates over 18000 bytes of storage, if
  44. this is coming from the local heap then you may simply not have enough room
  45. there (depends on how much global and static data you have as well as the
  46. size of the stack).
  47.  
  48.  
  49. ----------------------------------------------------------------------------
  50. Tom Brown               |  "She turned me into a newt...
  51. PE Nelson Systems       |                                  ... I got better"
  52. twbrown@pe-nelson.com   |                    Monty Python and the Holy Grail
  53. ----------------------------------------------------------------------------
  54.