Resources Low
3 messages in this thread
Hi,
Our application is using up resources but not properly releasing them when
finished …
The problem apprears to lie with our forms. About 60 bytes in USER Dgroup, 500
bytes
in one USER Private area and 1000 bytes in another USER Private area get used
and
are not released every time a form is opened and then closed. Eventually as
more forms
are opened/closed, we get a resources low message.
The first of the USER Private sections mentioned above appeares to contain text
for
menus …
We are using CMultiDocTemplate and each form typically has a menu, bitmaps for
buttons, string text for each entry field, and status bar text.
Any suggestions on what to look for in resolving this problem?
Glenn,
I've been down your road and know how frustrating a resource leak can be.
During my journey this forum's sysop (Don Schmitt) recommended several
articles:
ID: Q71455
INF:Tracking Down Loast System Resources
ID: Q66654
TITLE: INF: Possible Causes for System Resource Reduction
ID: Q72236
TITLE: INF: Maximizing the Use of Available Memory in Windows
Basically, I've found that MFVC does a pretty decent job of cleaning up after
itself, as far as dynamically allocated resources go. However, there are some
pitfalls to look out for:
1. Make sure to attach, using AddDocTemplate(), all document Template's that
you create — otherwise I believe that the resources associated with the
Template instance are not freed.
2. If you are using CFormView as a child window of a CFrameWnd (or derivative)
make sure that you do NOT associate a default menu with the form in App Studio
— otherwise MSVC will allocate the forms default menu in addition to the menu
associated with the frame (the CFormView's parent), but will not clean up the
resource allocation when you DestroyWindow() the frame.
Other than this, there are a variety of ways that one can loose resource heap
if you are allocating resources manually (basically by forgetting to free the
resource). However, if you're letting the frame do all of your resource
allocations, I would suggest you check out the above two possibilities.
Regards,
Brian
Brian,
Thanks for the references to those articles … I'll take a look at them as
soon as I finish this.
By the way, I think I have found the cause for my particular problems.
Apparently, assigning a menu to an MDI child window via App Studio is not the
thing to do. When
I removed these menu definitions, the USER objects no longer grew on
opening/closing
the window.