I have an application written in c++ to call interface routines to pull out data of a certain format.
Is was written in c++ 2003. I have a application written in c# which uses these DLLs to get data. It works fine.
I upgraded the application API to 2005 (C++) and the apllication which makes reference to these DLL c# 2005.
The interface uses non manage variable like char * whatever to be use as arguments to call interface routines to retrieve the data.
Ye I move data from the unmanage * char to manage String and forth.
I getting an memory corruption when the programs run for a certain period of time. It like I the GC never retrieves the memory release back to the heap.
This is how I do the clean up
Marshal::FreeHGlobal(IntPtr(whatever));
and this is always the location where I get the error...
Is always when I try to free the memory block...
The error not always happens with the same variable.
I will appreciate any help on this matter.
I'm struggling with this. I do make sure that when I create or assign a block of memery I release it later before it gets use the variable again. It could work fine 1, 2, 3 and sometimes runs through the program without causing the memory leak exception error but most of the time it does....
Well, which is it? Memory corruption or memory leak? Because they're two entirely different classes of errors.
Some things I would look into:
* Ensuring that the ownership of the pointers being returned by those functions is actually being transferred to me.
* Ensuring that I'm not screwing up some cast.
I do see the data coming out of the interface..... The data looks good. it just when it tries to release the memory block I get the error.... not always in the same spot.... which I told it could be memory leaks..... but anyway.... there are only four variables that I used for this purpose of moving the data from char * to String ^ and viceversa..... So I do know for fact that I do the same operations for all of them.... I appreciate any input...