I wrote a small example using pococapsule. When running it I can see
the process uses about 13 MB of RAM. The same process implemented
without pococapsule uses less than 1 MB.
Is that normal for pococapsule?
If I run multiple tasks will they each use extra 12 MB of RAM when
implemented with pococapsule or will this memory be allocated only
once and then shared between different tasks?
Is there a way to minimize the RAM usage?
I'm wondering whether to use pococapsule in an embedded system with
about 30 tasks running and using extra 400 MB of RAM is not possible.
Regards,
Slawomir
Sound like you were using the JNI XML reader. This is the default way
used by all PocoCapsule out-of-box examples. This XML reader will
simply start a Java VM inside the same process and use JNI to call the
xml parser inside that VM. By my understanding, the memory used by
this VM is not shared across POSIX processes (at least on Linux) by
other PocoCapsul's JNI XML reader. This XML reader is convenient for
demo and testing purpose. For real application, there are various
different ways that should have less memory consumption. For instance
(not an complete list):
1. simply use the Xerces-C++ xml parser. To do this, you simply put a -
lpocoxml option in your application link line. This will have the
memory consumption to be lower to few (I guess it should be less than
3) Mbytes.
2. Another way to significantly reduce the memory consumption is
simply handles the XML off-line, using the pxencode utility. This will
have the PocoCapsule's memory consumption (mostly shareable across
POSIX spaces) to less than 70K.
3. A third way is (if the off-line XML handling is not accessible) is
to use a separated task to deal with all XML handling on-line. Then,
PocoCapsule in each of these 40 tasks will only need ~70K memory. You
still have a single task that caused ~3M memory or so by the XML
handling engine (assuming you are using the Xercse C++). But, after
the XML handling, this task can be terminated to release that memory.
Ke
Ke
I played some tests tonight and found another easy approach you might
like to try. I am not sure what is your system (RT linux or VxWorks?)
but it works on Linux.
By this approach, you use the xerces-C XML parser based PocoCapsule
XML reader, the libpocoxml.so. But, instead of link this libpocoxml.so
to the main executable, you load it before handling XML deployment
documents and release it afterward.
For instance, on linux, you can simply do:
void* h = dlopen("libpocoxml.so", RTLD_LAZY|RTLD_GLOBAL); //
<---- !!
POCO_AppContext* ctxt1 = POCO_AppContext::create("setup1.xml",
"file");
POCO_AppContext* ctxt2 = POCO_AppContext::create("setup2.xml",
"file");
...
if( h != NULL ) dlclose(h); // <---- !!
...
ctxt1->initSingleton();
...
The xercse-C library (I am using still using the old version 2.7.1)
costs roughly 3.8M memory for its text and data segements (heap usage
isn't that significant for normal XML handling). On unloading the
libpocoxml.so, the dependent xerces-C library will also also be
unloaded and its text/data memory segement (~3.8M) are reclaimed by
the system (i.e. not simply be released to the heap memory pool of the
POSIX process) and can be reused to serve other processes (tasks).
Hope this helps,
Ke
On Mar 26, 4:18 am, Slawomir Czarko <slawomir.cza...@gmail.com> wrote: