none
Resource created in one thread and releasing in another thread

    Question

  • 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

    Friday, March 09, 2012 3:47 AM

Answers

  • 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

    Friday, March 09, 2012 7:46 PM

All replies

  • 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

    Friday, March 09, 2012 7:46 PM
  • 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

    Tuesday, March 13, 2012 3:11 AM