Tracking memory allocation

Jeff L lats at yless4u.com.au
Fri Oct 27 17:40:33 CDT 2006


Robert Shearman wrote:

> Jeff L wrote:
>
>> Robert Shearman wrote:
>
> Yes, it does. You can look at dlls/ntdll/tests/rtl.c to see how the 
> functions can be used.

Yep can see how that works now.

>> If I run out of handles, how do I reallocate the table or add to it?
>
> You can't. It is intended to be a fixed size table.

In this case I assume that if I allocate a big table it would be ok to 
fail calls for more memory at some point due to the table being full.

>> Are the functions thread safe if I anchor the handletable off a 
>> static variable in the dll?  I am going to need a persistent table 
>> for the life of the dll.  Hence it has the potential to be used by 
>> multiple threads.
>
> No. You need to protect the accessing of the handle table and handles 
> with a critical section.

Another way looks like using TlsAlloc in dllmain to allocate TlsIndex to 
provide separate the storage anchors between threads and thus build in 
thread safe behaviour.  Looks like an additional overhead in dll load 
and  thread creation as opposed to the use of a lot of critical sections 
(see 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/using_thread_local_storage_in_a_dynamic_link_library.asp).   
Is there any thought as to what the trade offs are in wine on the 2 
approaches?

Jeff




More information about the wine-devel mailing list