Resource created in one thread and releasing in another thread
-
venerdì 9 marzo 2012 03: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
Tutte le risposte
-
venerdì 9 marzo 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
- Proposto come risposta Rahul V. PatilModerator martedì 13 marzo 2012 03:07
- Contrassegnato come risposta drunkanmaster martedì 13 marzo 2012 03:43
-
martedì 13 marzo 2012 03:11Proprietario
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

