home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / mswindo / programm / misc / 979 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  2.7 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!Urmel.Informatik.RWTH-Aachen.DE!dfv.rwth-aachen.de!sungate.fido.de!p1.hippo.fido.de!softstream.fido.de!Thomas_Hornschuh
  2. Date: Wed, 22 Jul 92 20:21:04 +0200
  3. From: Thomas_Hornschuh@softstream.fido.de (Thomas Hornschuh)
  4. Subject: Re: Stack overflow and OWL error -6 (out of mem)
  5. Message-ID: <188d744c@p1.f36.n245.z2.fidonet.org>
  6. References: <d6bc5426@sofus.dhhalden.no>
  7. Newsgroups: comp.os.ms-windows.programmer.misc
  8. X-Comment-To: (Rune Halfdan Holst Huseby)
  9. Organization: SoftStream Development, Dortmund, Germany 
  10. Lines: 48
  11.  
  12. RH> So here the other day, after adding another module to the program, I got a
  13. RH> Stack Overflow. OK, I thought, I'll just raise STACKSIZE in my .DEF-file a
  14. RH> little bit (I had to raise it from 8000 to 21000, don't know why, the
  15. RH> module ain't recursive and don't contain much automatic variables).
  16.  
  17. Do you use some of the Windows Common Dialogs (Font, File Selector)? They 
  18. occupies much stack space.
  19.  
  20. RH>    1: How should I reduce the size of needed stack?
  21.  
  22. It's difficult, because Windows tends to be very recursive (nestet SendMessage 
  23. calls).
  24.  
  25. RH>    2: Is it possible to seperate det Stacksegment from the Datasegment?
  26.  
  27. Not directly in your app. But you can put most of your code in a DLL and only 
  28. the Startupcode in the EXE. Then the Datasegment for the .EXE can be entirely 
  29. used for the stack, and you DLL uses it's Data segment for Data only. But you 
  30. must deal with the SS!=DS issue, which is dificult in small and medium modell, 
  31. where library calls are want near data pointer.
  32.  
  33.  
  34. RH>    3: Should I use Large memory model (now I'm using Medium), even
  35. RH>       though it is recommended not doing so?
  36.  
  37. I think it's the easiest way. C++ objects in small and medium modell can only 
  38. be created at the local heap. To use far pointers, you must switch back to ugly 
  39. C structures. Or you can build only small objects, that contains far pointers 
  40. to the actual data. The objects would be only wrappers. Very error prone!
  41.  
  42. It's far easier to switch to large modell. The way Borland handles large modell 
  43. does not interfere with Windows memory managment. Borland by default stuffs all 
  44. static data in the automatic data segment and adresses it via the DS register 
  45. even in large modell. So it does not prevent windows from creating multiple 
  46. instances of the program.
  47.  
  48. MSC up to Version 6.0 always created a far data segment for the static data, 
  49. which prevents Windows from starting multiple instances of a program. The 
  50. problems with large modell have always been problems with MSC rather than 
  51. Windows.
  52.  
  53. Windows does not know anything about memory modell. It only asks: Does the 
  54. programm have one or more static data segments? If the answer is "one" Windows 
  55. is happy.
  56.  
  57.  
  58.  
  59.  
  60.