home *** CD-ROM | disk | FTP | other *** search
- 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
- Date: Wed, 22 Jul 92 20:21:04 +0200
- From: Thomas_Hornschuh@softstream.fido.de (Thomas Hornschuh)
- Subject: Re: Stack overflow and OWL error -6 (out of mem)
- Message-ID: <188d744c@p1.f36.n245.z2.fidonet.org>
- References: <d6bc5426@sofus.dhhalden.no>
- Newsgroups: comp.os.ms-windows.programmer.misc
- X-Comment-To: (Rune Halfdan Holst Huseby)
- Organization: SoftStream Development, Dortmund, Germany
- Lines: 48
-
- RH> So here the other day, after adding another module to the program, I got a
- RH> Stack Overflow. OK, I thought, I'll just raise STACKSIZE in my .DEF-file a
- RH> little bit (I had to raise it from 8000 to 21000, don't know why, the
- RH> module ain't recursive and don't contain much automatic variables).
-
- Do you use some of the Windows Common Dialogs (Font, File Selector)? They
- occupies much stack space.
-
- RH> 1: How should I reduce the size of needed stack?
-
- It's difficult, because Windows tends to be very recursive (nestet SendMessage
- calls).
-
- RH> 2: Is it possible to seperate det Stacksegment from the Datasegment?
-
- Not directly in your app. But you can put most of your code in a DLL and only
- the Startupcode in the EXE. Then the Datasegment for the .EXE can be entirely
- used for the stack, and you DLL uses it's Data segment for Data only. But you
- must deal with the SS!=DS issue, which is dificult in small and medium modell,
- where library calls are want near data pointer.
-
-
- RH> 3: Should I use Large memory model (now I'm using Medium), even
- RH> though it is recommended not doing so?
-
- I think it's the easiest way. C++ objects in small and medium modell can only
- be created at the local heap. To use far pointers, you must switch back to ugly
- C structures. Or you can build only small objects, that contains far pointers
- to the actual data. The objects would be only wrappers. Very error prone!
-
- It's far easier to switch to large modell. The way Borland handles large modell
- does not interfere with Windows memory managment. Borland by default stuffs all
- static data in the automatic data segment and adresses it via the DS register
- even in large modell. So it does not prevent windows from creating multiple
- instances of the program.
-
- MSC up to Version 6.0 always created a far data segment for the static data,
- which prevents Windows from starting multiple instances of a program. The
- problems with large modell have always been problems with MSC rather than
- Windows.
-
- Windows does not know anything about memory modell. It only asks: Does the
- programm have one or more static data segments? If the answer is "one" Windows
- is happy.
-
-
-
-
-