billroper: (Default)
[personal profile] billroper
It appears that we have a big memory leak in our application. Some of it is my fault, because I copied incorrectly working code without bothering to check how a particular class worked.

Short form: our COM routines return a BSTR. If you assign that BSTR value to an object of the CComBSTR class, the value is copied to the internal storage for the class instead of being attached to the internal storage. So if you were counting on the BSTR being cleaned up when the CComBSTR object went out of scope, well, you were right for one out of two strings.

*shudder*

The solution is to call the Attach method for the CComBSTR class so that it takes ownership of the pointer.

And happily, I figured this out before code freeze.

Now we just need to fix all of the places that are doing it wrong.

Date: 2013-03-07 05:41 am (UTC)
From: [personal profile] hms42
Glad to hear that the fix will make it into the final release, vs into a rushed patch to fix the issue.

Date: 2013-03-07 04:15 pm (UTC)
From: [identity profile] rono-60103.livejournal.com
I'd be surprised to learn that this kind of bug isn't the source of a lot of memory leaks in OO based programs.

We rely on the system garbage collector to clean up unreferenced objects, but don't always know where all the references are. Or, in this case, we only think we know where the references are.

As used to OO programming as I've gotten over the last several years, I still think that there may be some advantages to more procedural languages (C, assembly) where the programmer has a much better idea of what the machine is actually doing when executing their code.

Date: 2013-03-07 05:59 pm (UTC)
From: [identity profile] smoooom.livejournal.com
You can fix a memory leak? Perhaps you can hit my head or something at FKO because my memory leaks all over thr place. (G)

Profile

billroper: (Default)
billroper

February 2026

S M T W T F S
1 2 3 4 5 6 7
891011121314
15161718192021
22232425262728

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 9th, 2026 10:05 pm
Powered by Dreamwidth Studios