[xml] using sax + freeing mem
- From: aliban gmx net
- To: xml gnome org
- Subject: [xml] using sax + freeing mem
- Date: Sat, 14 Feb 2004 13:46:45 +0100
hi...
i got a problem using the sax parser. After having used it i have a
memory leak. i guess it is the parser context that does not get freed
properly.
(in fact if i do not call StreamBuffer_Add() the memory leak does not
appear... therefor the problem should be in there. the callback
functions of the sax are set to NULL;)
the code looks like this:
myclass::StreamBuffer_Add(const char *recvBuff,int iRecv)
{
bool bReturn false;
if(m_ptxmlParserCtx == 0)
{
//new parser ctx buffer required...
m_ptxmlParserCtx = xmlCreatePushParserCtxt(&x_SAXHandlerStruct,
this,
recvBuff,
4,
0);
if(m_ptxmlParserCtx != 0)
{
if(xmlParseChunk(m_ptxmlParserCtx, recvBuff+4, iRecv-4, 0) == 0)
{
bReturn = true;
}
}
}
else
{
if(xmlParseChunk(m_ptxmlParserCtx, recvBuff, iRecv, 0) == 0)
{
bReturn = true;
}
}
}
myclass::~myclass
{
if(m_ptxmlParserCtx != 0)
{
xmlFreeParserCtxt(m_ptxmlParserCtx);
m_ptxmlParserCtx = 0;
}
//xmlCleanupParser();
}
whatever there is still memory filled:
dump: see p.s.
i also added xmlCleanupParser(); in the destructor but that did not
help and will be called later anyway...
p.s.
00000072 3.46801311 [3280] Detected memory leaks!
00000073 3.46806871 [3280] Dumping objects ->
00000074 3.46819917 [3280] {5857}
00000075 3.46824303 [3280] normal block at 0x00CBF0D0, 20 bytes long.
00000076 3.46829415 [3280] Data: < @ T > 98 F0 CB 00 00
00 00 00 40 A6 54 00 00 00 00 00
00000077 3.46833243 [3280] {5856}
00000078 3.46837098 [3280] normal block at 0x00CBF098, 5 bytes long.
00000079 3.46841177 [3280] Data: <HTML > 48 54 4D 4C 00
00000080 3.46845702 [3280] {5855}
00000081 3.46849586 [3280] normal block at 0x00CBF050, 20 bytes long.
00000082 3.46856709 [3280] Data: < S S > 18 F0 CB 00 10
96 53 00 B0 96 53 00 00 00 00 00
00000083 3.46858050 [3280] {5854}
00000084 3.46861850 [3280] normal block at 0x00CBF018, 9 bytes long.
00000085 3.46866180 [3280] Data: <US-ASCII > 55 53 2D 41 53 43 49 49
00
00000086 3.46869895 [3280] {5853}
00000087 3.46874282 [3280] normal block at 0x00CBEFD0, 20 bytes long.
00000088 3.46879087 [3280] Data: < S S > 98 EF CB 00 10
96 53 00 B0 96 53 00 00 00 00 00
00000089 3.46882858 [3280] {5852}
00000090 3.46887440 [3280] normal block at 0x00CBEF98, 6 bytes long.
00000091 3.46891602 [3280] Data: <ASCII > 41 53 43 49 49 00
00000092 3.46895262 [3280] {5851}
00000093 3.46899089 [3280] normal block at 0x00CBEF50, 20 bytes long.
00000094 3.46903866 [3280] Data: < S S > 18 EF CB 00 F0
97 53 00 10 99 53 00 00 00 00 00
00000095 3.46907638 [3280] {5850}
00000096 3.46911465 [3280] normal block at 0x00CBEF18, 11 bytes long.
00000097 3.46915907 [3280] Data: <ISO-8859-1 > 49 53 4F 2D 38 38 35
39 2D 31 00
00000098 3.46919678 [3280] {5849}
00000099 3.46923506 [3280] normal block at 0x00CBEED0, 20 bytes long.
00000100 3.46931356 [3280] Data: < S S > 98 EE CB 00 20
9E 53 00 E0 9F 53 00 00 00 00 00
00000101 3.46932669 [3280] {5848}
00000102 3.46936440 [3280] normal block at 0x00CBEE98, 9 bytes long.
00000103 3.46940770 [3280] Data: <UTF-16BE > 55 54 46 2D 31 36 42 45
00
00000104 3.46944458 [3280] {5847}
00000105 3.46948285 [3280] normal block at 0x00CBEE50, 20 bytes long.
00000106 3.46953062 [3280] Data: < @ S S > 18 EE CB 00 40
9A 53 00 F0 9B 53 00 00 00 00 00
00000107 3.46956806 [3280] {5846}
00000108 3.46960633 [3280] normal block at 0x00CBEE18, 9 bytes long.
00000109 3.46964935 [3280] Data: <UTF-16LE > 55 54 46 2D 31 36 4C 45
00
00000110 3.46969349 [3280] {5845}
00000111 3.46973763 [3280] normal block at 0x00CBEDD0, 20 bytes long.
00000112 3.46978569 [3280] Data: < S S > B0 08 CC 00 B0
98 53 00 B0 98 53 00 00 00 00 00
00000113 3.46982312 [3280] {5844}
00000114 3.46986139 [3280] normal block at 0x00CC08B0, 6 bytes long.
00000115 3.46990246 [3280] Data: <UTF-8 > 55 54 46 2D 38 00
00000116 3.46993934 [3280] {5843}
00000117 3.46997761 [3280] normal block at 0x00CBECD8, 200 bytes
long.
00000118 3.47004941 [3280] Data: < P P > D0 ED CB 00 50
EE CB 00 D0 EE CB 00 50 EF CB 00
00000119 3.47006254 [3280] Object dump complete.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]