theRockLiu / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

[PATCH] Allows for overriding system allocator on Windows #567

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have implemented the missing support for setting the system allocator on 
Windows. This works the same way as in case of Linux and OS X, i.e. either by 
overriding the weakly defined tc_get_sysalloc_override function symbol or 
through MallocExtension::SetSystemAllocator method. The implementation closely 
follows the existing implementation in system-alloc.cc.

One of the consequences is that it is now possible to run system-alloc_unittest 
on Windows as well and I have added a Visual Studio project for that purpose. 
However, to make the project compilable, I had to inline the SysAllocator 
interface destructor definition as the original version didn't work when 
tcmalloc_minimal was built as DLL. This change shouldn't affect the existing 
code though.

Original issue reported on code.google.com by pho...@chromium.org on 25 Aug 2013 at 12:29

Attachments:

GoogleCodeExporter commented 9 years ago
I'm not slow with review. Just wondering if we can do better with 
dll_export-ing entire class. Which is afaik standard way to make sure 
constructors/destructors are available for inheritance.

Original comment by alkondratenko on 14 Sep 2013 at 8:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Do you mean the SysAllocator class?

Original comment by pho...@chromium.org on 14 Sep 2013 at 9:40

GoogleCodeExporter commented 9 years ago
Yes. I've yet to double check it. But my memory from past experience suggests 
that it might be a better way. It might also be needed for switch to 
-fvisibility=hidden for GNU/Linux as well (pending double checking too).

Original comment by alkondratenko on 14 Sep 2013 at 9:43