Configuration Script for Windows

Jos Vernon jv at
Thu Dec 24 02:31:57 PST 2015


Well the MinGW environment sounds interesting. Might try that. Thanks. :-)

My suspicions about the issues I am seeing are that they are related to
order of initialization of statics and tls. The MS runtime gets special
treatment so calling into new from a static initialization or a tls
initialization works just fine.

However jemalloc doesn't get this type of special treatment so I can see
that the order of initialization might be a bit random and that jemalloc
might only be partially set up at the point it is called. This would fit
with what I've reproduced so far which is related to odd behavior when
calling at the point of thread initialization.

More general allocation is fine. I exhaustively tested on our test suite
and there were no leaks at all. But that has a fairly fixed number of
threads which is why I didn't pick up the issues I describe above. It is
terribly impressive as well - produced a speed improvement of about 10%.
Though perhaps that says more about the MS runtime than it does about
jemalloc. :-)

I have always thought that the Windows DLL loading was terribly flaky.
Forget the fact that half of what you want to call has not yet been
initialized. The fact that you don't necessarily get all the thread load or
unload events is just mad. But that is MS all over - scared to fix things
for fear they might break them.


On Wed, Dec 23, 2015 at 5:05 PM, Jason Evans <jasone at> wrote:

> On Nov 19, 2015, at 2:08 AM, Jos Vernon <jv at> wrote:
> > I've been using the GitHub shines77/jemalloc-win32 for a while -  that
> uses jemalloc 3.6.0.
> >
> > However recently I've hit problems relating to leaks in highly threaded
> environments. I know these are jemalloc related because if I swap out
> jemalloc for a different memory manager then they go away.
> >
> > So it would seem to me that the first thing to do is to upgrade to 4.0.4
> to see if the issue is resolved. However I am having some problem getting
> this to work under MSVC.
> >
> > I can see that this is supposed to work because I can see MSVC bits in
> the config code. However there are lots of questions about this and a
> notable dearth of people who have been successful in this area. That
> includes me after my first day. :-(
> >
> > The MSVC bit is easy. It's getting the config to generate the right bits
> that is difficult.
> >
> > I'm using cygwin. I've put the Visual Studio 2012 environment variables
> into my shell so I can use MSVC CL and then I've done an ./
> CC=CL.
> >
> > This seems to work more or less ok. The results look feasible,.But then
> I'm missing important bits like sensible values in size_classes.h.
> >
> > I would love any pointers here. I'm pretty hot on VC++ so once I get the
> config going it will be fine. I am sure that will also be useful for other
> people who want to do similar things.
> Personally, the only thing I use Windows for is to fire up a 64-bit MinGW
> environment and build/test jemalloc.  I spent several days leading up to
> the 4.0.0 release making the test suite run and pass, but my lack of
> familiarity with modern Windows makes pretty much every experience with it
> intensely frustrating, and I keep hoping that others more familiar with
> Windows will round off the rough edges and document build procedures.  I've
> heard of people working around configuration issues to successfully build
> using Cygwin, and I'm pretty sure Mozilla uses MSVC with jemalloc.
> Jason


jos vernon
.NET Image Components & Consultancy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the jemalloc-discuss mailing list