Re: Creating Modeless Dialogs continually causing application to grow



Art wrote:
... Our users have made tight loops in the language that run a ton of different subroutines. Over time the main application grows in memory due to the frequency of running all these modeless dialogs. Adding the timer to give the main application a moment of rest seems to remove the modelss dialog memory growth. Complicated and hard to explain in a paragraph.

I'd welcome any comments should someone have more detailed knowledge of the windows event driven system and provide more insight into the problem.

A number of MFC calls create temporary objects (for example, GetDlgItem) that will occupy memory until MFC gets a chance to clean them up. It does such cleanup in idle time (CWinApp::OnIdle). So a possible explanation for what you are seeing is that OnIdle is seldom or never getting a chance to run. MFC's definition of "idle time" is checking the message queue and finding no messages to dispatch. So if you are keeping the message queue continually busy, or the processor continually busy, the temporary objects will tend to build up, awaiting idle time. By introducing your timer you have probably created some idle time bewteen timer messages.

--
Scott McPhillips [MVP VC++]

.



Relevant Pages

  • Re: Creating Modeless Dialogs continually causing application to grow
    ... Over time the main application grows in memory due ... does such cleanup in idle time. ... the message queue and finding no messages to dispatch. ... By introducing your timer you have probably created some idle time ...
    (microsoft.public.vc.mfc)
  • Re: Getting an out of memory error
    ... > I have a VBV.NET application that runs on a timer to do a job at one hour ... > the code executes an FTP transfer from an FTP site. ... > out of memory error message. ... you could end up running into memory problems. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: using volatile ptrs ...
    ... Let's assume that you have the necessary cast as well. ... > say that this memory is currently cached. ... If the message queue is in auto-answer mode, ... you will have the option of cancelling the program, debugging it, or ...
    (comp.lang.c)
  • Re: Thread.Sleep vs Thread.Join
    ... In other words, timer events queue ... when you call Join on the current thread you still pump ... when Join is called on a STA thread, otherwise it behaves 'like' a Sleep. ... You see there are two pre-requisites, you need a thread with a message queue ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Data caching question
    ... All this stuff is built in to ASP.NET ... I was thinking about making another caching singleton that would cache ... the CacheDB object would have a timer ... My primary concerns are the memory usages of in memory tables ...
    (microsoft.public.dotnet.framework.aspnet)

Loading