lechoo
February 14th, 2006, 02:32 PM
First of all I'm using Borland C++ Builder 6 and it's TThread objects.
My application is simple image converter. I have list of images and each of them is converted in a thread. I lauch only as many threads as there are procesors in system. When one of them has finished I create next until all images are converted.
At some point threads are allocating memory using new operator. This is where they crash (not instantly, but after some images are converted). This happens only on dual procesor machines. If I use multiple threads on single procesor machine everything works nice. My guess is that threads are trying to allocate same area of memory at same time. I know I can use TThread's Synchronize method or critical sections but since I use new in few places in different functions I'd like to keep my code clean.
Here's my question: is it possible to create area in memory for thread to use it? For example when new is called in thread, memory will be allocated inside this area. That way every thread will have it's own area and there will be no need for synchronization. Is it possible at all?
thanks in advance
My application is simple image converter. I have list of images and each of them is converted in a thread. I lauch only as many threads as there are procesors in system. When one of them has finished I create next until all images are converted.
At some point threads are allocating memory using new operator. This is where they crash (not instantly, but after some images are converted). This happens only on dual procesor machines. If I use multiple threads on single procesor machine everything works nice. My guess is that threads are trying to allocate same area of memory at same time. I know I can use TThread's Synchronize method or critical sections but since I use new in few places in different functions I'd like to keep my code clean.
Here's my question: is it possible to create area in memory for thread to use it? For example when new is called in thread, memory will be allocated inside this area. That way every thread will have it's own area and there will be no need for synchronization. Is it possible at all?
thanks in advance