Re: 2003 ActiveX control in .NET consumes memory when page is updated with setResults.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mark Nelson [MS] (marknel_at_online.microsoft.com)
Date: 04/21/04


Date: Tue, 20 Apr 2004 23:19:56 -0700

I believe the culprit here is garbage collection under .NET. Visio uses an
internal object list to track objects for automation. In COM programming,
releasing an automation object causes an immediate release from the internal
list. In .NET programming, the object doesn't go away until garbage
collection takes place. This can dramatically extend the lifetime of these
objects and result in the type of memory consumption you are seeing. I
believe the prescribed workaround is to force garbage collection to take
place, though this goes against the .NET philosophy of managed code.

-- 
Mark Nelson
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
"Joseph Gasiorek" <josephtsg@hotmail.com> wrote in message
news:2d705f30.0404201004.3fc31b3@posting.google.com...
> josephtsg@hotmail.com (Joseph Gasiorek) wrote in message
news:<2d705f30.0404190924.f4203dc@posting.google.com>...
> > I have placed the Visio ActiveX control on a form in .Net and I have a
> > timer that triggers every 100 m.s.
> >
> > When the Application initializes:
> > 1) load a document
> > 2) Disable UNDO,EVENTS, and AutoRecovery.
> > 3) Close down all unwanted windows
> >
> > On the timer Tick:
> > 1)Generate new values to update 3 shapes on the active page.
> > 2)Configure all parmeters for a SetResult call on the page
> > 3)Disable App.ScreenUpdating
> > 4)call SetResults
> > 5)Enable App.ScreenUpdating
> > 6)Use Marshal.ReleaseComObject(object), where objects are created for
> > manipulation of the page, application (in an attempt to clean up
> > memory -- it behaves the same way with out this)
> >
> > If I run this exe, you can see the Memory usage gradually increase (in
> > task manager).  So after 30 minutes my memory goes from 41meg to
> > 75meg, and keeps climbing.
> >
> > This is the first time I have used the control, I have had tremendous
> > success in doing a similar thing in a 2002 VSL.  Has any one else seen
> > this memory usage?
> >
> > Anyone have any ideas?
>
> I have investigate this more and found that a SetResults(that changes
> 3 cell values) or 3 seperate calls to the cells.ResultIU cause massive
> page faults.  By commenting out only the set result or 3 seperate
> calls, then no page faults exist and the application is well behaved.
>
> So why do writes that update the drawing cause page faults?


Relevant Pages

  • Re: Garbage Collection in C
    ... C++ didn't have garbage collection ... It encourages lax design & programming styles. ... It is the second time you mention this "pool libraries" for ressource ... if you call them to allocate, ...
    (comp.lang.c)
  • Re: Prolog module system
    ... I see no reason why objects in logic programming should ... Logtalk is the result of a set of design decisions (like any other OO ... an implicit identifier that you pass around. ... Garbage collection of objects would be nice. ...
    (comp.lang.prolog)
  • Re: A few newbie garbage collection questions
    ... Things have finally arranged themselves in my programming life that the ... If I plan to use garbage collection, do I just drop everything that I ... GC does not free you from having to think about memory ... The Garbage Collection Programming Guide talks about what you have to do ...
    (comp.sys.mac.programmer.help)
  • Re: Help about the complexity of code
    ... It is interesting that garbage collection is finally going mainstream. ... Object-Oriented programming had a similar history before C++. ... If you go back a little further, you find debates over subroutines. ... assembler, they said, you never learned enough about the architecture ...
    (rec.games.roguelike.development)
  • Re: garbage collection
    ... i am closing the form that increases the memory usage. ... variables and controls on the form disposed? ... >> i have a garbage collection problem. ... >> waiting 30 minutes but memory usage is not decreasing. ...
    (microsoft.public.dotnet.general)