Out of Memory troubles

ChristophChristoph Member Posts: 9
I try to unload all my tables with MSXML4.0 via a Automation Variable.
Generally (with Cronus) it works - i got my xml structures as I want.
But in my database with big tables like T32 I have got my troubles. It's can't handle them in once so I have to splitt them into blocks with 15000 records and save them step after step. Even this concepts works.
My problem now is that after a save and cleanup of all varables Navision want give me back all used memory. So in every turnaround Navision keps a part of the used memory until it came a message the navision has not enough memory to proceed on the task.

As had any of you a similar problem an how does you solved it?? Or have you any idea for a solution.

Thank's Christoph

Comments

  • PrebenRasmussenPrebenRasmussen Member Posts: 137
    This is a very old and well known 'feature' of Navision. It has never been very efficient at memory handling. Especially external components gives problems.

    One thing you try can try is to change the variables from local into global - or vice versa. It helped in earlier versions.
  • fbfb Member Posts: 246
    Sounds like you are using the XMLDom object model, which builds the entire XML file in-memory.

    Since you don't need access to the entire XML tree when streaming table data to disk, why not consider using the XMLSax object model, which has a much lower memory footprint.

    Here's a little toy to demonstrate (the code compiles and runs, but I've removed a bunch of stuff to make this readable):
    VAR (global)
      SAXWriter : 'Microsoft XML, v4.0'.MXXMLWriter40;
      ContentHandler : 'Microsoft XML, v4.0'.IVBSAXContentHandler;
      Attrib : 'Microsoft XML, v4.0'.SAXAttributes40;
      outFile : File;
      outStream : OutStream;
      NestLevel : Integer;
      ElemName : ARRAY [100] OF Text[30];
    BEGIN  
      // create outputfile, get an oStream...
      outFile.TEXTMODE(FALSE);
      outFile.WRITEMODE(TRUE);
      outFile.CREATE('c:\SaxWriterOutput.xml');
      outFile.CREATEOUTSTREAM(outStream);
    
      // create SAXWriter, set its properties and content handler...
      CREATE(SAXWriter);
      SAXWriter.omitXMLDeclaration(TRUE);
      SAXWriter.indent(TRUE);
      SAXWriter.output := outStream;
      ContentHandler := SAXWriter;
    
      // start doc, add elements, end doc...
      ContentHandler.startDocument();
      AddElement('book','cover','hard','',TRUE);
      AddElement('title','','','On the Circular Problem of Quadratic Equations',FALSE);
      EndElement;
      ContentHandler.endDocument();
    
      // tear everything down...
      CLEAR(SAXWriter);
      outFile.CLOSE;
    
      // warning if nesting level was not properly managed...
      IF NestLevel <> 0 THEN
        ERROR('AddElement (with children) not properly matched to EndElement calls...');
    END;
    
    PROCEDURE AddElement(elementName : Text[30];attribName : Text[30];attribValue : Text[30];elementText : Text[250];HasChildren : Boolean);
    VAR
      lTxt : Text[1];
    BEGIN
      IF ISCLEAR(Attrib) THEN CREATE(Attrib);
      lTxt := '';
    
      // set up attribute (if any)...
      Attrib.clear();
      IF attribName <> '' THEN
        Attrib.addAttribute('', '', attribName, '', attribValue);
    
      // add the element, and its text...
      ContentHandler.startElement(lTxt, lTxt, elementName, Attrib);
      IF elementText <> '' THEN
        ContentHandler.characters(elementText);
    
      // if element will have children, record the element name for later...
      // else, end the element...
      IF HasChildren THEN BEGIN
        NestLevel += 1;
        ElemName[NestLevel] := elementName;
      END ELSE BEGIN
        ContentHandler.endElement(lTxt, lTxt, elementName);
      END;
    END;
    
    PROCEDURE EndElement();
    VAR
      lTxt : Text[1];
    BEGIN
      // end an element, after its children have been added...
      IF NestLevel > 0 THEN BEGIN
        lTxt := '';
        ContentHandler.endElement(lTxt, lTxt, ElemName[NestLevel]);
        NestLevel -= 1;
      END;
    END;
    
  • eromeineromein Member Posts: 589
    or...

    Maybe you are using locals instead of globals. (was a issue back in the old days, before attain)

    Maybe you are using record references, there is a leak bug in there somewhere.

    But fb seems to have a good point!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • ChristophChristoph Member Posts: 9
    I wonna try the thing fb pointed out..

    my variables are as much as possible local..

    yes I using record references.. I wonna have a look to try to solve it in an other way..

    I wonna give some feedback, when I've got any new Infos..

    Thank you all for your help

    Christoph
  • PrebenRasmussenPrebenRasmussen Member Posts: 137
    Just saw your location is Zug, are you working at Integreat?
  • ChristophChristoph Member Posts: 9
    Not, I don't work for Integreat.. but I know, that they exist..
Sign In or Register to comment.