Resource created in one thread and releasing in another thread
-
2012年3月9日 3:47
hi
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?
thanks
yln
全部回复
-
2012年3月9日 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
- 已建议为答案 Rahul V. PatilModerator 2012年3月13日 3:07
- 已标记为答案 drunkanmaster 2012年3月13日 3:43
-
2012年3月13日 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

