parker@grapevine.uucp (Parker Waechter) (01/12/89)
An aplication I am writing seems to be holding 20K or so after the program terminates (as checked by command window aboutbox). I was careful about dealocating my pens and brushes, and the big blocks of memory are done with their LocalAlloc and GlobalAlloc (I do have a 9 byte block allocated in declaration ie BYTE x[9]). I call free's in my WM_DESTROY. Has anyone had a similar problem with their programs that could point me to something else to check? PS what is the difference between Local/GlobalFree and Local/GlobalDiscard? The man page for both says it returns memory to the heap, so what's the difference? ------------------ parker@sun.com No these are only my problems, opinions, questions...not anyone elses.
bturner@hpcvlx.HP.COM (Bill Turner) (01/14/89)
>An aplication I am writing seems to be holding 20K or so after the program >terminates (as checked by command window aboutbox). I was careful about >dealocating my pens and brushes,... Any fonts you've allocated and not freed? Only thing I can think of right off that could be that large... > PS what is the difference between Local/GlobalFree and Local/GlobalDiscard? > The man page for both says it returns memory to the heap, so what's the > difference? Free returns the memory to the heap and invalidates the handle. Discard returns the memory, but the handle is still valid. Normally, this is only used internally for (GL)MEM_DISCARDABLE, where the memory can be discarded without invalidating the handle. This can be quite useful for read-only data that can be retrieved from disc -- in fact, this is how discardable code and resources are done. I haven't seen any situations where you would want to explicitly call Local/GlobalDiscard, since the system should know better when to throw away memory. --Bill Turner
roper@june.cs.washington.edu (Michael Roper) (01/14/89)
Parker Waechter writes: > An aplication I am writing seems to be holding 20K or so after the > program terminates (as checked by command window aboutbox). Use Heapwalker. It comes with the Windows SDK. > What is the difference between Local/GlobalFree and Local/GlobalDiscard? *Free invalidates the memory handle if the function is successful. *Discard just ReAlloc's the memory block to zero, but the handle remains valid. Note that *Free returns hMem if it fails and *Discard returns hMem if it succeeds. Mike Roper
jonnyg@umd5.umd.edu (Jon Greenblatt) (01/15/89)
In article <33587@grapevine.uucp> parker@grapevine.uucp (Parker Waechter) writes: >An aplication I am writing seems to be holding 20K or so after the program >terminates (as checked by command window aboutbox). I was careful about >dealocating my pens and brushes, and the big blocks of memory are done with > >parker@sun.com I think the problem is with MS WINDOWS brain dead memory management. Memory is allocated from the global heap instead of a local processheap there causing a great deal of interprocess fragmentation. The about box in the command window is showing you the largest available block of memory, not the amount of memory available. Use heap walker to confim that the problem is in the heap structure. From my experience you don't have to close windows or destroy objects when terminating a process, its done for you. Please do not depend on brushes and windows going away automagicaly though, I'm sure the manual says to do it for a reason. JonnyG.