BUG: XML acumulando memoria

  • Follow


Percebi que ao processar aquivos XML usando a classe TXMLDOCUMENT est�
acumulando memoria.

Simulei o erro neste fonte em anexo com o proprio exemplo XMLTEST.PRG da
pasta SAMPLES do xHarbour.

Para simular o problema compile e execute o XMLTEST.EXE passando como
parametro o RECEBE.XML

A memoria vai se acumulando e chega uma hora que estoura.

Alguem tendo alguma dica me avise.


Obrigado,

Eduardo Motta


SOURCE CODE: XMLTEST.PRG

************************************************************
* xmltest.prg
* $Id: xmltest.prg,v 1.1 2009/05/12 01:31:08 modalsist Exp $
*
* Test for XML routines of Xharbour rtl (MXML/HBXML)
*
* USAGE:  xmltext <cFileName> <cNode> <cAttrib> <cValue> <cData>
*   cFileName: the XML to parse (defaults to xmltest.xml)
*   cNode: if you want to test regex match on node name
*   cNode: if you want to test if a node has an attribute
*   cValue: if you want to test if a node has an attribute with a given 
value
*   cData: if you want to test regex match on node content
*   (You can pass NIL/unused elements by setting them to "" on the command 
line)
*
* (C) Giancarlo Niccolai
*

#include "fileio.ch"
#include "hbxml.ch"
#include "common.ch"

Function Main( cFileName, cNode, cAttrib, cValue, cData )
Local nCont := 0
Default cFileName to "recebe.xml"

While LastKey() # 27
   TestXml( cFileName, cNode, cAttrib, cValue, cData )
   ThreadSleep(1)
   Inkey()
   ? nCont++
   HB_GCAll(.t.)
EndDo

Return

Function TestXml( cFileName, cNode, cAttrib, cValue, cData )
   Private hFile, cXml
   Private xmlDoc, xmlNode, lFind := .f.

   SET EXACT OFF
//   CLS

   ? "X H A R B O U R - XML Test "

   IF cFileName == NIL
      cFileName := "xmltest.xml"
   ENDIF

   // this can happen if I call xmltest filename "" cdata
   IF ValType( cNode ) == "C" .and. Len( cNode ) == 0
      cNode := NIL
   ENDIF

   // this can happen if I call xmltest filename "" cdata
   IF ValType( cAttrib ) == "C" .and. Len( cAttrib ) == 0
      cAttrib := NIL
   ENDIF

   // this can happen if I call xmltest filename "" cdata
   IF ValType( cValue ) == "C" .and. Len( cValue ) == 0
      cValue := NIL
   ENDIF

   if ! file( cFileName )
      @3, 10 SAY "File not found: " + cFileName
      @4,10 SAY "Terminating, press any key to continue"
      Inkey( .1 )
      RETURN
   ENDIF

   lFind := (cNode != NIL .or. cAttrib != NIL .or. cValue != NIL .or. cData 
!= NIL )

   ? "Processing "+cFileName+"..."

   oDoc := TXmlDocument():New( cFileName )
   //oNode := oDoc:oRoot:oChild
   oNode := oDoc:CurNode

   IF oDoc:nStatus != HBXML_STATUS_OK
      @4,10 SAY "Error While Processing File: "
      @5,10 SAY "On Line: " + AllTrim( Str( oDoc:nLine ) )
      @6,10 SAY "Error: " + oDoc:ErrorMsg
      @10,10 SAY "Program Terminating, press any key"
      Inkey( .1 )
      RETURN
   ENDIF

if ! lfind

   ? "XML Dump beginning here"
   ? "-----------------------"
   ? ""

   cXml := oDoc:ToString( HBXML_STYLE_NOINDENT )
   ? cXml
   ? "--- Press any key for next test"
//   Inkey(0)

   ? "-----------------------"
   ? "Navigating all nodes"
   ? ""

   DO WHILE oNode != NIL
      cXml := oNode:Path()
      IF cXml == NIL
         cXml :=  "(Node without path)"
      ENDIF

      ? Alltrim( Str( oNode:nType ) ), ", ", oNode:cName, " = ", ;
            ValToPrg( oNode:aAttributes ), ", ", oNode:cData, ": ", cXml

      oNode := oDoc:Next()
   ENDDO

else

   ?
   ? "Searching for node named", cNode, ",", cAttrib, "=", cValue,;
      " with data having", cData
   ? ""

   IF cNode != NIL
      cNode := HB_RegexComp( cNode )
   ENDIF
   IF cAttrib != NIL
      cAttrib := HB_RegexComp( cAttrib )
   ENDIF
   IF cValue != NIL
      cValue := HB_RegexComp( cValue )
   ENDIF
   IF cData != NIL
      cData := HB_RegexComp( cData )
   ENDIF

   oNode := oDoc:FindFirstRegex( cNode, cAttrib, cValue, cData )

   WHILE oNode != NIL
      ? "Found node ", oNode:Path() , ValToPrg( oNode:ToArray() )
      oNode := oDoc:FindNext()
   ENDDO

endif

   ?
   ? "Terminated. Press any key to continue"
//   Inkey( 0 )
   ?
   Release xmlDoc
   Release xmlNode

RETURN



// RECEBE.XML
<?xml version="1.0"?>
<coletor codigo="000030">
 <propriedades msgace="ACESSO LIBERADO BOM  APETITE !! " msgpad="RESTAURANTE 
GRSA" msgrec="ACESSO BLOQUEA  DO NO PER�ODO   " numreg="" status="0" 
ultmsg="NAO CONECTADO [-24]" ultreg=""/>
</coletor>



0
Reply Eduardo 3/10/2010 3:02:47 PM

To the Group:

Eduardo Motta is reporting a memory leak in the XML processing class,
apparently.

On Mar 10, 8:02=A0am, "Eduardo Motta" <emo...@gmail.com> wrote:
> Percebi que ao processar aquivos XML usando a
> classe TXMLDOCUMENT est=E1 acumulando memoria.
>
> Simulei o erro neste fonte em anexo com o proprio
> exemplo XMLTEST.PRG da pasta SAMPLES do xHarbour.
>
> Para simular o problema compile e execute o
> XMLTEST.EXE passando como parametro o RECEBE.XML
>
> A memoria vai se acumulando e chega uma hora que estoura.
>
> Alguem tendo alguma dica me avise.
>
> Obrigado,
>
> Eduardo Motta
....

Qual vers=E3o do xHarbour que voc=EA est=E1 usando, Eduardo? E qual sistema
operacional (n=E3o importa o que deveria)?

David A. Smith
0
Reply dlzc 3/10/2010 4:53:18 PM


xHarbour Comercial + Windows XP/VISTA/SEVEN
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6683)
Copyright 1999-2010, http://www.xharbour.org http://www.harbour-project.org/
Cannot open input file: a.prg



"dlzc" <dlzc1@cox.net> escreveu na mensagem 
news:3442a156-d0ec-48a1-94a4-447a56343777@m35g2000prh.googlegroups.com...
To the Group:

Eduardo Motta is reporting a memory leak in the XML processing class,
apparently.

On Mar 10, 8:02 am, "Eduardo Motta" <emo...@gmail.com> wrote:
> Percebi que ao processar aquivos XML usando a
> classe TXMLDOCUMENT est� acumulando memoria.
>
> Simulei o erro neste fonte em anexo com o proprio
> exemplo XMLTEST.PRG da pasta SAMPLES do xHarbour.
>
> Para simular o problema compile e execute o
> XMLTEST.EXE passando como parametro o RECEBE.XML
>
> A memoria vai se acumulando e chega uma hora que estoura.
>
> Alguem tendo alguma dica me avise.
>
> Obrigado,
>
> Eduardo Motta
....

Qual vers�o do xHarbour que voc� est� usando, Eduardo? E qual sistema
operacional (n�o importa o que deveria)?

David A. Smith 


0
Reply Eduardo 3/10/2010 6:23:32 PM

I can also confirm that there is a brutal loss of memory over time,
application 24h/day comes to 100MB of memory, an application for initial
7MG.

Using GCALL (), seemingly correcting a bit, but continues to increase.

This is a rather serious problem, because the applications does not
release the
memory used if TXML uses.

I've been looking at the source code if you saw something 'strange' and
apparently everything is correct.

Regards

-------------------------------------------------------------------------
Spanish ----------------------------------------------------------------
Yo tambi�n puedo confirmar que hay una perdida brutal de memoria con el
paso del tiempo, aplicaci�n 24h/d�a, llega a los 100MB de memoria, una
aplicaci�n de 7MG iniciales.

Usando GCALL(),aparentemente se corrige UN POCO, pero sigue increment�ndose.

Esto es un problema bastante grave, pues las aplicaciones NO LIBERAN la
memoria usada si se hace uso de TXML.

He estado mirando el c�digo fuente por si veia alguna cosa 'extra�a', y
aparentemente todo est� correcto.

Saludos
Rafa Carmona

0
Reply rafa 3/16/2010 8:28:49 AM

3 Replies
461 Views

(page loaded in 0.079 seconds)

Similiar Articles:

7/17/2012 2:40:18 AM


Reply: