9 มีนาคม 2555 3:47
i am creating resourcing ( any thing from simple memory to kernal Objects ) in one thread and using it . But iam alloting resource
releasing to another thread .so far it is working fine. But my technical lead is saying this is a problem.but i ran the program 24 X7
and checking memory status and stack . so far not a problem . But When the Problem comes?.is there any restricted resource that
should release the resource in the created thread only ? any such kind of examples?
9 มีนาคม 2555 19:46
kernel objects don't have thread affinity with respect to creating/deleting those objects.
not to be confused with "releasing" them as in ReleaseMutex (which has to be called from the same thread that acquired that mutex). In this case people say that Mutex DOES have thread affinity. It's just not with respect to creating / deleting mutex
Regular (as opposed to customized in many different forms) memory allocation in C++ (new / delete ) also can be newed/deleted in different threads
13 มีนาคม 2555 3:11เจ้าของ
Beyond what dimkaz has said, one additional caveat is that memory created by a dll must be freed by the same dll. So if you are passing objects around and doing the memory management manually, you must be careful to not cross dll boundaries.
Rahul V. Patil