Resource created in one thread and releasing in another thread
-
9. března 2012 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
Všechny reakce
-
9. března 2012 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
- Navržen jako odpověď Rahul V. PatilModerator 13. března 2012 3:07
- Označen jako odpověď drunkanmaster 13. března 2012 3:43
-
13. března 2012 3:11Vlastník
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