The Dam Has Burst! Run For Your Lives!
Mar. 6th, 2013 09:45 pmIt 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.
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.
no subject
Date: 2013-03-07 05:41 am (UTC)no subject
Date: 2013-03-07 04:15 pm (UTC)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.
no subject
Date: 2013-03-07 05:12 pm (UTC)You (and in this case myself included) need to know what the properties of an object are before you use it. I relied on the existing use case in the code being correct when I started coding instead of going to the documentation myself and reading it to be sure that what I was doing was the right thing.
no subject
Date: 2013-03-07 05:59 pm (UTC)no subject
Date: 2013-03-14 04:15 am (UTC)(Now where's my Silly Putty...?)