Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Does MSXML3 on WinCE 5.0 leak huge amounts of memory?

From: AntonievanWoerdekom@-----------.---------.---
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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent