Hi Srini,
I am not familiar with the memory management of linux/unixes in deep. I wrote a small test programm, that allocates some memory with new and frees the memory with delete. Using the same information of "/proc/self/statm", the memory usage goes up and down. Maybe the pages of the free pool will not be counted for "/proc/self/statm". Therefore the pages are in use by Xalan/Xerces. (or maybe my argumentation is wrong ;^)
I try to make a Windows Build this evening to see what will happen on Win32.
HolgeR
[EMAIL PROTECTED] schrieb:
Holger,
This is how memory allocation works on UNIXes. The heap size of a process usually only goes up or stays the same. As objects are freed/deleted, the space is kept in a free pool and reused for future maloc/callocs. I am not aware of any malloc library [public domain or commercially] malloc libraries that can release memory.
Srini
-----Original Message----- From: Holger Fl�rke To: [email protected] Sent: 5/26/2004 3:14 AM Subject: Re: Memory Leak in Xalan-C 1.7?
I have some more information about this topic. This behaviour could be observed on Xalan-C 1.8 (unmodified) and Xerces-C 2.5 (unmodified) on SuSE9.1, too. The good news: It is not a memory leak.
If I destroy each stylesheet after one compile/transform run, the memory
will not grow. I think this behavior can be explained by some preallocated (and reused) memory within Xalan. But how I get rid of this memory? The destruction of XalanTransformer, even a terminate of the whole library does not seem to work.
HolgeR
Holger Fl�rke schrieb:
> Hi there, > > I have tried to compile multiple Stylesheets, store the pointers to > the compiled stylesheets within a stl list, do some transformations, and > destroy the stylesheets one after another. After each stylesheet > compilation and after each stylesheet destruction, I glimpsed into > /proc/self/statm, the memory usage of the current process on linux > machines. I was wondering why the memory usage stays at a high level > even after the destruction of the compiled stylesheets and the > termination of the library. > > Is there anywhere a memory leak with the usage of multiple compiled > stylesheets? Or am I wrong with my interpretation of the memory usage of > the process? Does anybody see the same results? > > I have attached the source of the test, a modified version of the > compiled stylesheet example. It does only run on linux machines. You > have to put the foo*-files from the compiled stylesheet sample within > the same directory. I used this on RedHat WS3.0 with "gcc version 3.2.3 > 20030502 (Red Hat Linux 3.2.3-24)", Xalan-C 1.7 (slightly modifed) and
> Xerces-C 2.4 (slightly modifed). My results are: > Start > 821 821 763 4 813 4 58 > compiled Stylesheet #0 > 1140 1140 1052 4 1102 34 88 > compiled Stylesheet #1 > 1150 1150 1052 4 1102 44 98 > compiled Stylesheet #2 > 1157 1157 1052 4 1102 51 105 > compiled Stylesheet #3 > 1166 1166 1052 4 1102 60 114 > compiled Stylesheet #4 > 1173 1173 1052 4 1102 67 121 > compiled Stylesheet #5 > 1180 1180 1052 4 1102 74 128 > compiled Stylesheet #6 > 1186 1186 1052 4 1102 80 134 > compiled Stylesheet #7 > 1192 1192 1052 4 1102 86 140 > compiled Stylesheet #8 > 1199 1199 1052 4 1102 93 147 > compiled Stylesheet #9 > 1206 1206 1052 4 1102 100 154 > ... > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > destroying Stylesheet > 1262 1262 1100 4 1150 108 162 > Xalan terminated > 1264 1264 1102 4 1152 108 162 > Xerces terminated > 1266 1266 1104 4 1154 108 162 > End > > Regards, > > HolgeR
-- holger floerke d o c t r o n i c email [EMAIL PROTECTED] information publishing + retrieval phone +49 2222 9292 90 http://www.doctronic.de
-- holger floerke d o c t r o n i c email [EMAIL PROTECTED] information publishing + retrieval phone +49 2222 9292 90 http://www.doctronic.de
#include <stdio.h> #include <iostream> using namespace std;
void printMem()
{
FILE* fIn = fopen("/proc/self/statm","r");
char buf[256];
fgets(buf,255,fIn);
fclose(fIn);
cout << buf;
}
int main()
{
cout << "before all ";
printMem();
for (int i=0; i < 2; i++)
{
char* pBigMem = new char[1024*1024];
for (int j = 0; j < 1024*1024; j++)
{
pBigMem[j] = 0;
};
cout << "after allocate ";
printMem();
delete[] pBigMem;
cout << "after release ";
printMem();
cout << endl;
};
cout << "after all ";
printMem();
cout << endl;
return 0;
}
