Allocating memory for an object on one thread and deleting it on another thread? I thought that was ok and that thread share heap space?
Maybe this is not the source of the problem and I have look deeper.
Printable View
Allocating memory for an object on one thread and deleting it on another thread? I thought that was ok and that thread share heap space?
Maybe this is not the source of the problem and I have look deeper.
Should be safe enough, provided you synchronize properly.
+1Quote:
Originally Posted by Lindley
+1 , but , make sure no matter what, allocaiton and deallocation happen through the same module. Read here:
http://blogs.msdn.com/oldnewthing/ar...15/755966.aspx
http://social.msdn.microsoft.com/For...-7a0969366b1a/
Quote:
Originally Posted by Rigel
Horribly Illegal, and the software police are on their way to arrest you. :D
Seriously, like the others pointed out, it is generally 100% safe if:
1) You are allocating/releasing the the general heap
2) You have the proper synchronization in place.
The reason I am responsding is that there is also the concepts to TLS [Thread Local Storage] and some environments provide access for a dedicated heap along with this. IF you are using TLS, then the memory refereces are only guaranteed to be valid for the thread in question, and any access (not just a new/delete) is illegal.