created COM component in C# and called it in VBA. VBA Code:

Sub test()

For i = 1 To 1000
    Dim p As ClassLibrary1.Point
    Set p = New ClassLibrary1.Point
    Dim surface As ClassLibrary1.surface
    Set surface = New ClassLibrary1.surface
    Debug.Print surface.Create(p)
Next i

End Sub

ClassLibrary1 consists of a DLL and a TLB (which I reference in my VBA)
ClassLibrary1 has classes and respective interfaces for Point and Surface.
When I run this, Excel causes an increase in memory (as seen from Windows Task Manager)
of 700KB (approx) and every time I run this, it increases and remains constant.
I tried setting the objects to 'Nothing' but it doesnt help. Any ideas?

share|improve this question
Don't use 1000, use a billion. – Hans Passant Feb 2 '11 at 16:19
I get your point Hans. Same thing as below. My program levelled out at 87k in Mem usage and stayed constant after that. – arhsim Feb 4 '11 at 13:48
feedback

1 Answer

up vote 1 down vote accepted

You probably don't actually have a problem the task manger reports the Working Set

The working set of a program is a collection of those pages in its virtual address space that have been recently referenced. It includes both shared and private data. The shared data includes pages that contain all instructions your application executes, including those in your DLLs and the system DLLs. As the working set size increases, memory demand increases.

You might want to see what the private bytes are which represent the actual memory that you are using. See this article from Tess Ferrandez

share|improve this answer
Thanks a lot!! And your explanation is dot on! Thanks again. – arhsim Feb 4 '11 at 13:47
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.