C++ COM obj in VB 
Author Message
 C++ COM obj in VB

I have the wierdest problem with a COM object I'm writing in VC++.  The
reason I'm posting here is because I have a 'test mule' application in which
I instantiate it to test it.  In one of my functions, I get an error
(originating in VB) any time I attempt to free memory (using either free or
delete, depeding on how I allocated it) or realloc a memory block to a
different size.  I have other functions in my COM object in which I can free
memory.

I've reduced the number of variables for which I explicitly allocate memory
as much as possible, but there are some things one just can't do without
while programming. ;-)  The only thing that I've been able to come up with
is that perhaps VB uses some kind of memory management that is intercepting
my calls to malloc and subsequent calls to free or realloc are in conflict
with the alleged memory manager.  Can anyone confirm or refute this?

If anyone is interested and thinks they can help me, let me know and I'll
send you my function's source code (don't want to waste the bandwidth here).
We need to get this working as soon as possible, as we are to ship on Oct.
25.  I've opened a case with MS, but have not gotten very far with it.

Thanks for your time.

Tim Wallace



Sat, 02 Apr 2005 06:28:11 GMT  
 C++ COM obj in VB
Is the object your trying to change memory on.....   something that is
possibly referenced by VB through the interface ?


Quote:
> I have the wierdest problem with a COM object I'm writing in VC++.  The
> reason I'm posting here is because I have a 'test mule' application in
which
> I instantiate it to test it.  In one of my functions, I get an error
> (originating in VB) any time I attempt to free memory (using either free
or
> delete, depeding on how I allocated it) or realloc a memory block to a
> different size.  I have other functions in my COM object in which I can
free
> memory.

> I've reduced the number of variables for which I explicitly allocate
memory
> as much as possible, but there are some things one just can't do without
> while programming. ;-)  The only thing that I've been able to come up with
> is that perhaps VB uses some kind of memory management that is
intercepting
> my calls to malloc and subsequent calls to free or realloc are in conflict
> with the alleged memory manager.  Can anyone confirm or refute this?

> If anyone is interested and thinks they can help me, let me know and I'll
> send you my function's source code (don't want to waste the bandwidth
here).
> We need to get this working as soon as possible, as we are to ship on Oct.
> 25.  I've opened a case with MS, but have not gotten very far with it.

> Thanks for your time.

> Tim Wallace



Sat, 02 Apr 2005 06:30:28 GMT  
 C++ COM obj in VB
Steve:

Thanks for your reply.

No, I only attempt to allocate/reallocate memory used inside of my function.
Unless VB is intercepting calls to malloc and using its own heap, VB never
'sees' my memory.

Tim


Quote:
> Is the object your trying to change memory on.....   something that is
> possibly referenced by VB through the interface ?



> > I have the wierdest problem with a COM object I'm writing in VC++.  The
> > reason I'm posting here is because I have a 'test mule' application in
> which
> > I instantiate it to test it.  In one of my functions, I get an error
> > (originating in VB) any time I attempt to free memory (using either free
> or
> > delete, depeding on how I allocated it) or realloc a memory block to a
> > different size.  I have other functions in my COM object in which I can
> free
> > memory.

> > I've reduced the number of variables for which I explicitly allocate
> memory
> > as much as possible, but there are some things one just can't do without
> > while programming. ;-)  The only thing that I've been able to come up
with
> > is that perhaps VB uses some kind of memory management that is
> intercepting
> > my calls to malloc and subsequent calls to free or realloc are in
conflict
> > with the alleged memory manager.  Can anyone confirm or refute this?

> > If anyone is interested and thinks they can help me, let me know and
I'll
> > send you my function's source code (don't want to waste the bandwidth
> here).
> > We need to get this working as soon as possible, as we are to ship on
Oct.
> > 25.  I've opened a case with MS, but have not gotten very far with it.

> > Thanks for your time.

> > Tim Wallace



Sat, 02 Apr 2005 06:43:13 GMT  
 C++ COM obj in VB
TIM....   guess I should have mentioned....   about the difference between
ByRef and ByVal.....    just something to think about...


Quote:
> I have the wierdest problem with a COM object I'm writing in VC++.  The
> reason I'm posting here is because I have a 'test mule' application in
which
> I instantiate it to test it.  In one of my functions, I get an error
> (originating in VB) any time I attempt to free memory (using either free
or
> delete, depeding on how I allocated it) or realloc a memory block to a
> different size.  I have other functions in my COM object in which I can
free
> memory.

> I've reduced the number of variables for which I explicitly allocate
memory
> as much as possible, but there are some things one just can't do without
> while programming. ;-)  The only thing that I've been able to come up with
> is that perhaps VB uses some kind of memory management that is
intercepting
> my calls to malloc and subsequent calls to free or realloc are in conflict
> with the alleged memory manager.  Can anyone confirm or refute this?

> If anyone is interested and thinks they can help me, let me know and I'll
> send you my function's source code (don't want to waste the bandwidth
here).
> We need to get this working as soon as possible, as we are to ship on Oct.
> 25.  I've opened a case with MS, but have not gotten very far with it.

> Thanks for your time.

> Tim Wallace



Sat, 02 Apr 2005 08:02:17 GMT  
 C++ COM obj in VB
Tim,

I've never seen anything like this. Have you tried using IMalloc or the heap
APIs directly instead? Are you 100% sure the fault is happening in the VB
runtime and not somewhere on your code?

VB shouldn't even see or be bothered about your memory allocations, at all.

. . . . . . . . . . . . . . . . . . . . . .
Klaus H. Probst, MVP
   http://www.vbbox.com/

Please post/reply to the newsgroup(s)


Quote:
> I have the wierdest problem with a COM object I'm writing in VC++.  The
> reason I'm posting here is because I have a 'test mule' application in
which
> I instantiate it to test it.  In one of my functions, I get an error
> (originating in VB) any time I attempt to free memory (using either free
or
> delete, depeding on how I allocated it) or realloc a memory block to a
> different size.  I have other functions in my COM object in which I can
free
> memory.

> I've reduced the number of variables for which I explicitly allocate
memory
> as much as possible, but there are some things one just can't do without
> while programming. ;-)  The only thing that I've been able to come up with
> is that perhaps VB uses some kind of memory management that is
intercepting
> my calls to malloc and subsequent calls to free or realloc are in conflict
> with the alleged memory manager.  Can anyone confirm or refute this?

> If anyone is interested and thinks they can help me, let me know and I'll
> send you my function's source code (don't want to waste the bandwidth
here).
> We need to get this working as soon as possible, as we are to ship on Oct.
> 25.  I've opened a case with MS, but have not gotten very far with it.

> Thanks for your time.

> Tim Wallace



Sat, 02 Apr 2005 08:07:17 GMT  
 C++ COM obj in VB
Klaus:

The error happens after a call to free() or realloc() in my DLL.  When I
walk down the code after this call, I get to a point in the system DLLs
where it is ASSERTing that the memory it is about to free is in its own
heap.  This ASSERT fails.  I have no idea why, as  the memory was allocated
by my code using malloc() and was not freed prior to this call.

I am stumped.

Tim



Quote:
> Tim,

> I've never seen anything like this. Have you tried using IMalloc or the
heap
> APIs directly instead? Are you 100% sure the fault is happening in the VB
> runtime and not somewhere on your code?

> VB shouldn't even see or be bothered about your memory allocations, at
all.

> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
>    http://www.vbbox.com/

> Please post/reply to the newsgroup(s)



> > I have the wierdest problem with a COM object I'm writing in VC++.  The
> > reason I'm posting here is because I have a 'test mule' application in
> which
> > I instantiate it to test it.  In one of my functions, I get an error
> > (originating in VB) any time I attempt to free memory (using either free
> or
> > delete, depeding on how I allocated it) or realloc a memory block to a
> > different size.  I have other functions in my COM object in which I can
> free
> > memory.

> > I've reduced the number of variables for which I explicitly allocate
> memory
> > as much as possible, but there are some things one just can't do without
> > while programming. ;-)  The only thing that I've been able to come up
with
> > is that perhaps VB uses some kind of memory management that is
> intercepting
> > my calls to malloc and subsequent calls to free or realloc are in
conflict
> > with the alleged memory manager.  Can anyone confirm or refute this?

> > If anyone is interested and thinks they can help me, let me know and
I'll
> > send you my function's source code (don't want to waste the bandwidth
> here).
> > We need to get this working as soon as possible, as we are to ship on
Oct.
> > 25.  I've opened a case with MS, but have not gotten very far with it.

> > Thanks for your time.

> > Tim Wallace



Sat, 02 Apr 2005 22:18:28 GMT  
 C++ COM obj in VB
I just tried using CoTaskMemAlloc/CoTaskMemRealloc, and I get the error on
CoTaskMemRealloc.

Tim



Quote:
> Tim,

> I've never seen anything like this. Have you tried using IMalloc or the
heap
> APIs directly instead? Are you 100% sure the fault is happening in the VB
> runtime and not somewhere on your code?

> VB shouldn't even see or be bothered about your memory allocations, at
all.

> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
>    http://www.vbbox.com/

> Please post/reply to the newsgroup(s)



> > I have the wierdest problem with a COM object I'm writing in VC++.  The
> > reason I'm posting here is because I have a 'test mule' application in
> which
> > I instantiate it to test it.  In one of my functions, I get an error
> > (originating in VB) any time I attempt to free memory (using either free
> or
> > delete, depeding on how I allocated it) or realloc a memory block to a
> > different size.  I have other functions in my COM object in which I can
> free
> > memory.

> > I've reduced the number of variables for which I explicitly allocate
> memory
> > as much as possible, but there are some things one just can't do without
> > while programming. ;-)  The only thing that I've been able to come up
with
> > is that perhaps VB uses some kind of memory management that is
> intercepting
> > my calls to malloc and subsequent calls to free or realloc are in
conflict
> > with the alleged memory manager.  Can anyone confirm or refute this?

> > If anyone is interested and thinks they can help me, let me know and
I'll
> > send you my function's source code (don't want to waste the bandwidth
> here).
> > We need to get this working as soon as possible, as we are to ship on
Oct.
> > 25.  I've opened a case with MS, but have not gotten very far with it.

> > Thanks for your time.

> > Tim Wallace



Sat, 02 Apr 2005 22:36:14 GMT  
 C++ COM obj in VB
As of my last post, I had only change the malloc/free of one var to IMalloc
methods.  I received an error on the IMalloc calls.  I went back to my code
and changed all malloc/free combos to IMalloc calls and now the error
message is gone.  Strange but true.

Thanks for you help.

Tim



Quote:
> Tim,

> I've never seen anything like this. Have you tried using IMalloc or the
heap
> APIs directly instead? Are you 100% sure the fault is happening in the VB
> runtime and not somewhere on your code?

> VB shouldn't even see or be bothered about your memory allocations, at
all.

> . . . . . . . . . . . . . . . . . . . . . .
> Klaus H. Probst, MVP
>    http://www.vbbox.com/

> Please post/reply to the newsgroup(s)



> > I have the wierdest problem with a COM object I'm writing in VC++.  The
> > reason I'm posting here is because I have a 'test mule' application in
> which
> > I instantiate it to test it.  In one of my functions, I get an error
> > (originating in VB) any time I attempt to free memory (using either free
> or
> > delete, depeding on how I allocated it) or realloc a memory block to a
> > different size.  I have other functions in my COM object in which I can
> free
> > memory.

> > I've reduced the number of variables for which I explicitly allocate
> memory
> > as much as possible, but there are some things one just can't do without
> > while programming. ;-)  The only thing that I've been able to come up
with
> > is that perhaps VB uses some kind of memory management that is
> intercepting
> > my calls to malloc and subsequent calls to free or realloc are in
conflict
> > with the alleged memory manager.  Can anyone confirm or refute this?

> > If anyone is interested and thinks they can help me, let me know and
I'll
> > send you my function's source code (don't want to waste the bandwidth
> here).
> > We need to get this working as soon as possible, as we are to ship on
Oct.
> > 25.  I've opened a case with MS, but have not gotten very far with it.

> > Thanks for your time.

> > Tim Wallace



Sun, 03 Apr 2005 02:45:23 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Linking my obj file to C++

2. Problem using Visual C++ generated .obj files with QB4.5

3. Using VB COM Objects in Visual C++ 5

4. Using events in VB from a C++ COM object

5. COM/COM+ in VB or C++

6. error after closing c++ com used by vb

7. VB call C++ COM.

8. VB & C++ COM Components Talking

9. VB C++ DirectX and COM

10. Call C++ Routines in VB COM

11. Querying COM Interfaces From VB Like You Can In C++

12. Calling a C++ COM object from a VB program

 

 
Powered by phpBB® Forum Software