|
From: Kumar P. <kpr...@ad...> - 2007-08-09 10:47:03
|
Hi,
=20
=20
I have tried following sample code with DevPartner (for VC8) and found
the memory leaks.=20
=20
int main(void)
{
// Test word breaking
UErrorCode status =3D U_ZERO_ERROR;
=20
BreakIterator *bi =3D
BreakIterator::createWordInstance(Locale("th"), status);
UChar text[] =3D {0x0E19, 0x0E01, 0x0E1A, 0x0E19, 0x0E1A, 0x0E01,
0};
=20
bi->setText(text);
int32_t p =3D bi->first();
printf("\n");
while (p !=3D BreakIterator::DONE) {
printf("Boundary at position %d\n", p);
p =3D bi->next();
}
delete bi;
u_cleanup();
=20
return 0;
=20
}
=20
=20
Call stack shown is -
=20
icu\source\common\cmemory.c (45): uprv_malloc_3_6
source\common\uobject.cpp (60): icu_3_6::UMemory::operator new
source\common\locid.cpp (163): icu_3_6::locale_set_default_internal
source\common\locid.cpp (674): icu_3_6::Locale::getDefault
source\common\locid.cpp (265): locale_get_default_3_6
common\uloc.c (2009): uloc_getDefault_3_6
source\common\uresbund.c (382): findFirstExisting
source\common\uresbund.c (455): entryOpen
source\common\uresbund.c (1867): ures_open_3_6
source\common\brkiter.cpp (71):
icu_3_6::BreakIterator::buildInstance
source\common\brkiter.cpp (416):
icu_3_6::BreakIterator::makeInstance
source\common\brkiter.cpp (396):
icu_3_6::BreakIterator::createInstance
source\common\brkiter.cpp (151):
icu_3_6::BreakIterator::createWordInstance
=20
=20
I investigated a bit and found that memory was not being cleaned before
returning at line no 179 in locid.cpp. When I used
"ucln_common_registerCleanup(UCLN_COMMON_LOCALE, locale_cleanup);" at
line no 178 (before returning) and build icu again for testing, it works
fine and gives no memory leak.
=20
Is it a known problem? Can I go ahead with the solution mentioned above?
=20
=20
Thanks,
Pratyush
=20
|