Problem with memory
Sanjay -- SGUPTA@aegonusa.com Friday, June 14, 1996 MSVC 1.52 Windows 3.11 I have a pretty complex application which allocates large dynamic arrays. Also, application uses form views in which all the data input fields are also created dynamically. In other words, form view can have edit controls, static text controls, bitmaps etc. which are all created dynamically at run time with their individual fonts and colors. The applciation also uses property sheets -templates for the pages are created through AppStudio, however the controls are created in each page at run time just as in form view. I am facing two problems: 1. As I stay in my application, available physical RAM always goes on decreasing and finally goes to zero but application keeps on working fine - I don't see any problems. What bothers me is that as I allocate memory, I also free memory but memory never goes up. However I do get all me memory back when I exit my app. 2. When I have a property sheet up, the application uses up lot of resources. Even though as each page is changed, I clean up all the dynamically created memory, but for some reason resources for all the pages stay used up which are reclaimes as soon as you close the property sheet. I am using a third party utility WinPRobe to monitor resources and memory. I really do need solution to this. I have tested my app with BoundsChecker and there are no memory or resource leaks. Any help will be greatly appreciated. Thanks. Sanjay
funduc@sprynet.com Saturday, June 22, 1996 If you're using malloc and free, you shouldn't. That's because they go dirctly to DOS memory allocation routines and Windows doesn't know when you freed it. There is a routine that will help synch Windows memory managers but you should use GlobalAlloc/LocalAlloc, especially in Windows 3.1. If that's not the problem, try describing your environment (OS, type of allocations etc.). On Fri, 14 Jun 1996, "Gupta, Sanjay"wrote: > >MSVC 1.52 >Windows 3.11 > >I have a pretty complex application which allocates large dynamic arrays. >Also, application uses form views in which all the data input fields are >also created dynamically. In other words, form view can have edit controls, >static text controls, bitmaps etc. which are all created dynamically at run >time with their individual fonts and colors. The applciation also uses >property sheets -templates for the pages are created through AppStudio, >however the controls are created in each page at run time just as in form >view. I am facing two problems: > >1. As I stay in my application, available physical RAM always goes on >decreasing and finally goes to zero but application keeps on working fine - >I don't see any problems. What bothers me is that as I allocate memory, I >also free memory but memory never goes up. However I do get all me memory >back when I exit my app. > >2. When I have a property sheet up, the application uses up lot of >resources. Even though as each page is changed, I clean up all the >dynamically created memory, but for some reason resources for all the pages >stay used up which are reclaimes as soon as you close the property sheet. > >I am using a third party utility WinPRobe to monitor resources and memory. > >I really do need solution to this. I have tested my app with BoundsChecker >and there are no memory or resource leaks. Any help will be greatly >appreciated. > >Thanks. > >Sanjay > Mike Funduc Funduc Software Inc. funduc@sprynet.com 102372.2530@compuserve.com http://home.sprynet.com/sprynet/funduc http://ourworld.compuserve.com/homepages/funduc
Brad Wilson/Crucial Software -- crucial@pobox.com Monday, June 24, 1996 [Mini-digest: 2 responses] > If you're using malloc and free, you shouldn't. That's because they go > dirctly to DOS memory allocation routines and Windows doesn't know when > you freed it. There is a routine that will help synch Windows memory > managers but you should use GlobalAlloc/LocalAlloc, especially in > Windows 3.1. If that's not the problem, try describing your > environment (OS, type of allocations etc.). This doesn't make any sense. The C runtime library implementation for malloc and free would be calls to LocalAlloc() and LocalFree(), respectively. You cannot just "go directly to DOS memory allocation routines" and get moveable protected mode memory for a windows application. -- Brad Wilson crucial@pobox.com http://pobox.com/~crucial Software engineering services for Microsoft Windows NT and Windows 95 "If everything is coming your way, then you're in the wrong lane." -----From: craigtt@ccmail.PE-Nelson.COM As to the resouce consumption in your property sheet, what you're seeing is caused by the fact that all the pages are created when the sheet is created. The pages are then simply displayed or hidden as the tabs are walked through. You get a window for each control on each page and window handles leave a relatively large footprint on resouces in 16 bit Windows. If you absolutely have to reduce the resouce hit from the property sheet, the only way I know of is to dynamically create the controls as a page becomes active and destroy them when it becomes inactive. I imagine this will be a good bit of work. Tim Craig PE-Nelson
Niels Ull Jacobsen -- nuj@kruger.dk Wednesday, June 26, 1996 At 14:08 14-06-96 -0500, you wrote: > >MSVC 1.52 >Windows 3.11 > >I have a pretty complex application which allocates large dynamic arrays= .=20 >Also, application uses form views in which all the data input fields are= =20 >also created dynamically. In other words, form view can have edit contro= ls,=20 >static text controls, bitmaps etc. which are all created dynamically at = run=20 >time with their individual fonts and colors. The applciation also uses=20 >property sheets -templates for the pages are created through AppStudio,=20 >however the controls are created in each page at run time just as in for= m=20 >view. I am facing two problems: > >1. As I stay in my application, available physical RAM always goes on=20 >decreasing and finally goes to zero but application keeps on working fin= e -=20 >I don't see any problems. What bothers me is that as I allocate memory, = I=20 >also free memory but memory never goes up. However I do get all me memor= y=20 >back when I exit my app. MSVC 1.52 and 2.X use suballocators. They allocate memory in large chunks using LocalAlloc and subdivide it for malloc/freee and new/delete. Unfortunately, they never release memory to Windows once they have=20 allocated it, unless you call _heapmin(). So just call _heapmin() once in a while (e.g. in your OnIdle()). > >2. When I have a property sheet up, the application uses up lot of=20 >resources. Even though as each page is changed, I clean up all the=20 >dynamically created memory, but for some reason resources for all the pa= ges=20 >stay used up which are reclaimes as soon as you close the property sheet. Resources are not the same as memory. Do you destroy all the windows=20 you create as soon as you don't need them anymore? Performance will=20 suffer, but you could probably destroy all the controls on a given page=20 once it loses focus. And don't create them until you're sure you need the= m. Finally, if several controls use the same font, make sure to keep only on= e=20 copy of it. Fonts are rather large and expensive. >I am using a third party utility WinPRobe to monitor resources and memor= y. > >I really do need solution to this. I have tested my app with BoundsCheck= er=20 >and there are no memory or resource leaks. Any help will be greatly=20 >appreciated. > >Thanks. > >Sanjay Niels Ull Jacobsen, Kr=FCger A/S (nuj@kruger.dk) Everything stated herein is THE OFFICIAL POLICY of the entire Kruger=20 group and should be taken as legally binding in every respect.=20 Pigs will grow wings and fly.
| Вернуться в корень Архива |