Leaky strings

When the ‘bad string’ line in the following code is used I get a big memory leak, but when the ‘good string’ line is used there is no memory leak.

from ROOT import std
test = std.string()

for n in xrange(int(1e6)):
   if n % 10000 == 0: print 'entry: ', n

   #s = 'good string'
   s = std.string('bad string')
   test.replace( 0, std.string.npos, s )

Does anyone understand where the memory leak is coming from?
Any help would be greatly appreciated.

Thanks,
Andrew

PS. I’m running ROOT v5.34/01 with python 2.7.3, gcc 4.01, on osx 10.6.8

Andrew,

not totally understanding it yet, but this should fix it:import ROOT ROOT.std.string.replace._mempolicy = ROOT.kMemoryStrict
HTH,
Wim

Hi,

found it; fix is in v5-34-00-patches. Thanks for reporting!

Cheers,
Wim

Thanks very much, your suggestion fixed the leak. I will try the patches next time I upgrade ROOT.

Cheers,
Andrew