Click here to Skip to main content
15,887,987 members
Home / Discussions / COM
   

COM

 
GeneralRe: Convert System.__ComObject to a class Pin
DeepToot17-Aug-09 10:34
DeepToot17-Aug-09 10:34 
GeneralRe: Convert System.__ComObject to a class Pin
warale00121-Oct-09 1:30
warale00121-Oct-09 1:30 
QuestionHolding a WMI provider instance Pin
srikanthos16-Aug-09 21:38
srikanthos16-Aug-09 21:38 
Questiondraw Visualization in custom directshow [modified] Pin
raj157616-Aug-09 19:43
raj157616-Aug-09 19:43 
QuestionMODI Microsoft Document Image Viewer 11 and 12 Pin Pin
JollyMansArt15-Aug-09 4:35
JollyMansArt15-Aug-09 4:35 
QuestionHow can I disable a KillBit for a special CLSID in a secure environment? Pin
ieaeitsch11-Aug-09 5:31
ieaeitsch11-Aug-09 5:31 
QuestionHow to set Caption and ToolTip to Toolbar button Pin
am 200910-Aug-09 22:47
am 200910-Aug-09 22:47 
QuestionQuestion about VARIANT deallocation Pin
GuimaSun10-Aug-09 4:53
GuimaSun10-Aug-09 4:53 
After more than 8 hours trying to fix up a memory leak I need some help :/


I have a ATL COM component, with the following interface:

STDMETHODIMP CDCSClient::CallService( VARIANT *p1 )


Inside the method I do the following:

VariantClear( p );
VariantInit( p );
p->vt = VT_BSTR | VT_BYREF;
BSTR *pBSTR = new BSTR;
*pBSTR = SysAllocString( L"abc" );
p->pbstrVal = pBSTR;


And my client in VB is like this:

For i = 1 To 1000
Dim myInt As Integer
myInt = 3
ret = client.CallService(myInt)
Next


As far as I know the COM engine is creating a VARIANT from my integer (which is received as VT_BYREF | VT_I2), and I change it to VT_BSTR.
The VB loop causes a huge memory leak.
Am I doing something wrong ? How the COM engine handles the new VARIANT/BSTR deallocation ?

Thanks for any help.


AnswerRe: Question about VARIANT deallocation Pin
Hristo-Bojilov10-Aug-09 6:12
Hristo-Bojilov10-Aug-09 6:12 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun10-Aug-09 6:27
GuimaSun10-Aug-09 6:27 
GeneralRe: Question about VARIANT deallocation Pin
Hristo-Bojilov10-Aug-09 6:45
Hristo-Bojilov10-Aug-09 6:45 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun10-Aug-09 7:08
GuimaSun10-Aug-09 7:08 
AnswerRe: Question about VARIANT deallocation Pin
Stuart Dootson10-Aug-09 8:21
professionalStuart Dootson10-Aug-09 8:21 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun10-Aug-09 8:43
GuimaSun10-Aug-09 8:43 
AnswerRe: Question about VARIANT deallocation Pin
Vi210-Aug-09 22:01
Vi210-Aug-09 22:01 
GeneralRe: Question about VARIANT deallocation Pin
GuimaSun12-Aug-09 4:12
GuimaSun12-Aug-09 4:12 
GeneralRe: Question about VARIANT deallocation Pin
Vi212-Aug-09 21:37
Vi212-Aug-09 21:37 
GeneralRe: Question about VARIANT deallocation Pin
Vi213-Aug-09 0:20
Vi213-Aug-09 0:20 
Questioncalling messagebox funtion from a c# code Pin
nicetohaveyou8-Aug-09 8:22
nicetohaveyou8-Aug-09 8:22 
AnswerRe: calling messagebox funtion from a c# code Pin
Hristo-Bojilov10-Aug-09 3:27
Hristo-Bojilov10-Aug-09 3:27 
QuestionInvalidCastException by registering events on Office Add-In Pin
maesi19808-Aug-09 5:54
maesi19808-Aug-09 5:54 
AnswerRe: InvalidCastException by registering events on Office Add-In [modified] Pin
maesi198010-Aug-09 0:45
maesi198010-Aug-09 0:45 
QuestionCom Component Pin
sekannak6-Aug-09 23:58
sekannak6-Aug-09 23:58 
AnswerRe: Com Component Pin
Randor 9-Aug-09 9:53
professional Randor 9-Aug-09 9:53 
GeneralRe: Com Component Pin
sekannak9-Aug-09 18:57
sekannak9-Aug-09 18:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.