Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!shadooby!mailrus!iuvax!purdue!bu-cs!mirror!mguyott From: mguyott@mirror.UUCP (Marc Guyott) Newsgroups: comp.windows.ms Subject: Global memory loss under MS Windows. Keywords: MakeProcInstance, FreeProcInstance, global memory Message-ID: <33666@mirror.UUCP> Date: 6 Dec 89 16:23:41 GMT Reply-To: mguyott@prism.TMC.COM (Marc Guyott) Organization: Mirror Systems, Cambridge Mass. Lines: 52 Here is something that Jim Champeaux discovered here at Mirror Systems. I am curious to learn if anyone else has experienced similar problems. The basic problem is that calling MakeProcInstance() when it is not needed [even though Microsoft says it is OK but not necessary to call MakeProcInstance() in our particular case] even with matching FreeProcInstance() calls ends up slowly using up all of free memory. It appears that each call to MakeProcInstance() and FreeProcInstance() uses up 96 bytes of global memory. Our program was crashing due to insufficient free memory after about 4000 iterations through the code that contained the MakeProcInstance() and FreeProcInstance() calls. Removing the unnecessary MakeProcInstance() and FreeProcInstance() calls solved the memory loss problem. We reported this to Microsoft via On-Line but we have not yet heard anything from them. Marc ---- "All my life I always wanted to BE somebody. I see now I should have been more specific." Jane Wagner Marc Guyott mguyott@mirror.tmc.com {mit-eddie, pyramid, harvard!wjh12, xait}!mirror!mguyott Mirror Systems Cambridge, MA 02140 617/661-0777 ---- /* Written 2:01 pm Dec 4, 1989 by jvc@prism.TMC.COM */ /* ---------- "Global Memory Loss" ---------- */ Read this if your are experiencing global memory loss. According to Microsoft, MakeProcInstance() "is not required if the module has a single data segment for all instances". DLLs are such a creature. However, it seems their wording is not strong enough. We (tools group) have found that it might actually be detrimental to use MakeProcInstance() in a DLL. WinTester had this problem of eating up global memory. It would keep allocating 96 byte blocks of memory to support a linked list. From what we can tell this linked list contained nothing but nulls. In our case, we were also not using FreeProcInstance() since Microsoft also states "MakeProcInstance can create no more than one procedure instance of an application. This means that after a procedure instance has been created, subsequent calls using the same function and instance return the same result.". We only had four or five functions which needed (we thought) procedure instance addresses and these functions were called repeatedly. Well, we installed FreeProcInstance() in all locations appropriate and the same problem continued. We finally removed the MakeProcInstance()/FreeProcInstance() calls (remember, Microsoft said they weren't required) and used the address of the function directly. Problem solved, no more eating global memory. /* End of text from prism:ms.clps.common */