Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - RE: Does MSXML3 on WinCE 5.0 leak huge amounts of memory? Does MSXML3 on WinCE 5.0 leak huge amounts of memory?To: NULL Date: 5/2/2006 9:53:00 AM
Hi,
I have written an application on WinCE 5.0 (with the March 2006 patches
applied) that does stores an XDR schema in an XMLSchemaCache. I am pretty
confident that this application itself does not leak memory, but,
nethertheless, WinCE runs out. Please help!
The following code excerpt provides reproduction steps. One would imagine
that the for loop in _tmain could run infinitely without the program running
out of memory. In fact, on Windows 2000, this does run ok, but on WinCE 5.0
it does not...
// XmlSchemaCacheTest.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <windows.h>
#include <msxml2.h>
#include <comdef.h>
static const TCHAR *g_szSchema =
_T("<xd:Schema")
_T(" xmlns:xd=\"urn:schemas-microsoft-com:xml-data\"")
_T(" xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">")
_T(" <xd:ElementType name=\"Item1\" model=\"closed\">")
_T(" <xd:datatype dt:type=\"string\"/>")
_T(" </xd:ElementType>")
_T(" <xd:ElementType name=\"Item2\" model=\"closed\"")
_T(" dt:type=\"enumeration\" dt:values=\"Good Bad Ugly\"/>")
_T(" <xd:ElementType name=\"Item3\" model=\"closed\">")
_T(" <xd:datatype dt:type=\"ui4\" dt:maxExclusive=\"100\"/>")
_T(" </xd:ElementType>")
_T(" <xd:ElementType name=\"RegisteredObject\" model=\"closed\"
content=\"eltOnly\" order=\"seq\">")
_T(" <xd:AttributeType name=\"InstanceID\" dt:type=\"string\"
required=\"no\"/>")
_T(" <xd:attribute type=\"InstanceID\"/>")
_T(" <xd:element type=\"Item1\"/>")
_T(" <xd:element type=\"Item2\"/>")
_T(" <xd:element type=\"Item3\"/>")
_T(" </xd:ElementType>")
_T("</xd:Schema>")
;
void DoSomethingWithSchemaCache()
{
IXMLDOMSchemaCollection* pSchemaCache;
IXMLDOMDocument2 *pSchema;
// Create a schema cache
CoCreateInstance(CLSID_XMLSchemaCache, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMSchemaCollection, (LPVOID *)&pSchemaCache);
// Create a DOM document and fill it with an XDR schema
CoCreateInstance( CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2, (LPVOID *)&pSchema );
pSchema->put_async(VARIANT_FALSE);
pSchema->put_validateOnParse(VARIANT_FALSE);
VARIANT_BOOL fIsSuccess;
pSchema->loadXML(_bstr_t(g_szSchema), &fIsSuccess);
// Add the schema to the cache
pSchemaCache->add(_bstr_t(_T("")), _variant_t( pSchema ) );
// And take it out again
pSchemaCache->remove(_bstr_t(_T("")));
// Release the interfaces
pSchemaCache->Release();
pSchema->Release();
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
DoSomethingWithSchemaCache();
DoSomethingWithSchemaCache();
for (int i = 0; i < 1000; i++)
{
DoSomethingWithSchemaCache();
}
CoUninitialize();
return 0;
}
--
Antonie van Woerdekom
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
