<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I’m using C Sharp MapScript to access MapServer (MS4W 3.0.6).  I’m creating a new mapObj from an almost empty MAPFILE and then dynamically add layers to the map and then calling draw to generate an image.  I’m also dynamically adding symbolObjs
 to the map’s symbolset for the layers to reference.  This all works great the vast majority of the time, but on rare occasions, sometime after the map has been generated, I receive the following AccessViolationException when garbage collection is attempting
 to clean up the MapServer objects.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">System.AccessViolationException was unhandled<o:p></o:p></p>
<p class="MsoNormal">  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.<o:p></o:p></p>
<p class="MsoNormal">  Source=mapscript_csharp<o:p></o:p></p>
<p class="MsoNormal">  StackTrace:<o:p></o:p></p>
<p class="MsoNormal">       at OSGeo.MapServer.mapscriptPINVOKE.delete_symbolObj(HandleRef jarg1)<o:p></o:p></p>
<p class="MsoNormal">       at OSGeo.MapServer.symbolObj.Dispose()<o:p></o:p></p>
<p class="MsoNormal">       at OSGeo.MapServer.symbolObj.Finalize()<o:p></o:p></p>
<p class="MsoNormal">  InnerException:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve tried disposing of the map itself, its symbolset, as well as each symbolObj item in that symbolset by calling Dispose on each, but doing so neither causes the error to happen immediately upon calling Dispose (instead it still only
 happens when garbage collection runs) nor does it do anything to resolve the issue.  I don’t see any reference to symbolObj in the map layers (looks like it just holds a symbol name and/or index) nor anywhere else that stands out as a logical place to look,
 so I don’t see anything else to dispose.  Does anyone have any idea of where I could look for any symbolObjs which have been allocated so I can dispose of them so that garbage collection does not choke when attempting to dispose of them for me?  Am I barking
 up the wrong tree and should be looking somewhere else entirely rather than focusing on symbolObj?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for any guidance that can be provided,<o:p></o:p></p>
<p class="MsoNormal">John<o:p></o:p></p>
</div>
</body>
</html>