Hi,

 

I recently asked this on stack overflow boost with icu u32_regex memory leak / cache on Win32 but haven’t been able to solve issue yet so thought I would ask here as well.

 

The problem I’m having is that I can’t seem to clean up the ICU data when it is loaded by boost regex using the optional icu linkage to support Unicode regex’s.

 

I’ll copy the example source I posted above:-

 

#define BOOST_TEST_MAIN    //Ask boost unit test framework to create a main for us
#define BOOST_ALL_DYN_LINK //Ask boost to link to dynamic library rather than purely header support where appropriate
#include <boost/test/auto_unit_test.hpp>

#include <boost/regex.hpp>
#include <boost/regex/icu.hpp> //We use icu extensions to regex to support unicode searches on utf-8
#include <unicode/uclean.h>    //We want to be able to clean up ICU cached objects

BOOST_AUTO_TEST_CASE( standard_regex )
{
    boost::regex re( "\\d{3}");
}

BOOST_AUTO_TEST_CASE( u32_regex )
{
    boost::u32regex re( boost::make_u32regex("\\d{3}"));
    u_cleanup(); //Ask the ICU library to clean up any cached memory
}

 

Which may be compiled at command prompt (cl version 16 from vs2010) with appropriate directories inserted if not pathed in on machine.

 

cl test.cpp /I[BOOST HEADERS PATH] /I[ICU HEADERS] /EHsc /MDd -link /LIBPATH:[BOOST LIB PATH] [ICU LIB PATH]icuuc.lib

 

The problem I have with this is that the u_cleanup() does not cleanup so the unit test framework reports memory leaks (at least that is what I think is going on) :-

 

Just compiling the 1st test case will work perfectly – adding in the 2nd test case (with or without the u_cleanup() ) will generate a memory leak report

 

Running 2 test cases...

 

*** No errors detected

Detected memory leaks!

Dumping objects ->

{778} normal block at 0x00668530, 28 bytes long.

Data: <    0N W        > 00 00 00 00 30 4E C2 57 00 00 00 00 01 00 00 00

{777} normal block at 0x004C5AF8, 14 bytes long.

Data: <icudt46l-coll > 69 63 75 64 74 34 36 6C 2D 63 6F 6C 6C 00

{776} normal block at 0x004C5200, 5 bytes long.

Data: <root > 72 6F 6F 74 00

{775} normal block at 0x004C9B30, 60 bytes long.

Data: < RL  ZL         > 00 52 4C 00 F8 5A 4C 00 00 00 00 00 00 00 00 00

… rest removed for clarity

 

As it says in comment on original post icu appears to be loaded as a dynamic link so I can’t see why u_cleanup() would not work – alternatively I can’t find any calls in boost::regex library which would allow me to ask it to clean up icu cache.

 

Thanks in advance for any help.

 

Alex