Merrin
Merrin

Reputation: 524

Memory problem with PowerBuilder 11.5 and C# COM component

First of all, sorry for my english.

I'm developing a COM component in C# (which implements IDisposable) to use it from PowerBuilder something like this:

OLEObject lole_comComponent

lole_comComponent = Create OLEObject
lole_comComponent.ConnectToNewObject("MyComComponent")

[Do some stuff...]

lole_component.DisconnectObject()
destroy lole_component
GarbageCollect()

With this code, destructor of COM Component is triggered when close de app. I've added a method to the component that calls a private Dispose method. Something like this:

OLEObject lole_comComponent

lole_comComponent = Create OLEObject
lole_comComponent.ConnectToNewObject("MyComComponent")

[Do some stuff...]

lole_component.Close()  // this method calls Dispose(true)
lole_component.DisconnectObject()
destroy lole_component

GarbageCollect()

In neither of the two examples the memory used by the component is released.

How I can free the memory used by the COM component?

I'm using PowerBuilder 11.5.1 Build 4740.

Upvotes: 2

Views: 1535

Answers (1)

Terry
Terry

Reputation: 6215

I'll confess to being fuzzy on who is owning the memory in this situation, PowerBuilder or the control, but one fact that may be helpful (or not) is the fact that PowerBuilder tends to hang on to memory it gets allocated from the OS. The theory is that memory requests are performance expensive operations, so instead of going through cycles of requesting and releasing memory (PB doesn't know what you're going to do next), it just hangs onto memory it has requested and doesn't need right now.

HTH,

Terry.

Upvotes: 1

Related Questions