Click here to Skip to main content
16,004,564 members

Comments by Keanu L (Top 21 by date)

Keanu L 19-Apr-13 4:04am View    
Of Course i do as you say , i allocate the memory in calling function and free it in calling function .The Debug Version works fine ,and when i debug the Release Version ,it has no exception but when running the release version ,it throws the exception.
************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Keanu L 18-Apr-13 11:16am View    
I'm sorry that the code belongs to a project ,so i need to keep secret......
Keanu L 18-Apr-13 11:12am View    
i had a dll which creates Thread using CreateThread and in this thread, there is class var declared in calling function( using operator new ) passed by point will allocate memory ( using malloc ) in this thread , after exit the thread, the calling function will clean up this class var including the memory allocated in thread , so i want to know is this operaton thread-safe.In some book <<Windows via C/C++>> said the C++/C Runtime librray does not allow two threads allocate the memory using malloc at the same time. i think in all my threads, the class var will allocate the memory but will not clean up and all the clean up operation is done by the calling function which breaks the heap and leads to my problem.
Keanu L 27-Mar-13 8:52am View    
Thank you for your explanation. I have underundered the problem.You are right , from the view of compiler i should consider the program logic.
Keanu L 27-Mar-13 8:16am View    
In gcc, the int and the emun are allocated the same memory size 4 bytes, so it should be safe.