Re: JESS: [EXTERNAL] Question on QueryResult close() function

"Peter Lin" <[email protected]> Fri, 28 Jun 2013 10:02:29 -0400
Newsgroups gmane.comp.java.jess
Message-ID <CAKv2g8fi0NxEcfKj6OL1uDUmSXm3PQ-cNfjxqS98CwmrrVQ=wA@mail.gmail.com>
--bcaec501638b50a3f004e037542e
Content-Type: text/plain;
 charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Hi Daniel,

How are you measuring the leak?

It is important to look at the heap used and not the total heap allocated
to the JVM process. What I've done in the past with JESS is write a
function that uses java's runtime class to get actual memory used stats.

        Runtime rt =3D Runtime.getRuntime();
        long free =3D rt.freeMemory();
        long total =3D rt.totalMemory();

If you have concerns about JVM heap getting to big, then set -Xmx to the
value you desire. If runtime stats don't help, your only viable option is
to use a profiling tool like YourKit, JProbe or some other profiler to
track down the leak.

peter


On Fri, Jun 28, 2013 at 9:21 AM, Friedman-Hill, Ernest
<[email protected]>wrote:

>  Hi Daniel,****
>
> ** **
>
> Closing a QueryResult doesn=92t really do anything important; normal garb=
age
> collection will free all of its resources.****
>
> ** **
>
> I used Google to see if there was a standard Jess/Matlab integration that
> I didn=92t know about, but I didn=92t find one; I=92m afraid I don=92t kn=
ow
> anything about how Jess and Matlab are typically used together. Jess does
> =93warm up=94 for a few iterations if run repeatedly with the same rules =
=96
> i.e., =93(reset)=94 won=92t necessarily get you back to the same memory u=
sage as
> before the first run =96 but this levels off quickly. It would be a good =
idea
> to run a heap analyzer tool to see what kind of objects are being leaked;
> that might give us a clue as to what=92s happening.****
>
> ** **
>
> *From:* [email protected] [mailto:[email protected]] =
*On
> Behalf Of *Daniel Selva
> *Sent:* Thursday, June 27, 2013 12:53 PM
> *To:* jess-users
> *Subject:* JESS: [EXTERNAL] Question on QueryResult close() function****
>
> ** **
>
> Hi,****
>
> ** **
>
> I am experiencing a memory leak problem in a Matlab-Jess application and =
I
> am trying to locate the leak. I came across the definition of the close()
> method of the QueryResult class. I have never called this method after
> using queries. ****
>
> ** **
>
> 1) Should I call close() after using a query?****
>
> 2) Could not calling close() be the cause of the leak? ****
>
> ** **
>
> If not, I would appreciate any tips on typical causes of leaks in
> Matlab-Jess applications. ****
>
> ** **
>
> Thanks in advance,****
>
>
> Daniel****
>

--bcaec501638b50a3f004e037542e
Content-Type: text/html;
 charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div><br></div>Hi Daniel,<br><br></div=
>How are you measuring the leak?<br><br></div>It is important to look at th=
e heap used and not the total heap allocated to the JVM process. What I&#39=
;ve done in the past with JESS is write a function that uses java&#39;s run=
time class to get actual memory used stats.<br>
<br>=A0=A0=A0 =A0=A0=A0 Runtime rt =3D Runtime.getRuntime();<br>=A0=A0=A0 =
=A0=A0=A0 long free =3D rt.freeMemory();<br>=A0=A0=A0 =A0=A0=A0 long total =
=3D rt.totalMemory();<br><br></div>If you have concerns about JVM heap gett=
ing to big, then set -Xmx to the value you desire. If runtime stats don&#39=
;t help, your only viable option is to use a profiling tool like YourKit, J=
Probe or some other profiler to track down the leak.<br>
<br></div>peter<br></div><div class=3D"gmail_extra"><br><br><div class=3D"g=
mail_quote">On Fri, Jun 28, 2013 at 9:21 AM, Friedman-Hill, Ernest <span di=
r=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">ejfri=
[email protected]</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">





<div link=3D"blue" vlink=3D"purple" lang=3D"EN-US">
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">Hi Daniel,<u></u><u></u><=
/span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">Closing a QueryResult doe=
sn=92t really do anything important; normal garbage collection will free al=
l of its resources.<u></u><u></u></span></p>

<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d">I used Google to see if t=
here was a standard Jess/Matlab integration that I didn=92t know about, but=
 I didn=92t find one; I=92m afraid I don=92t know anything about
 how Jess and Matlab are typically used together. Jess does =93warm up=94 f=
or a few iterations if run repeatedly with the same rules =96 i.e., =93(res=
et)=94 won=92t necessarily get you back to the same memory usage as before =
the first run =96 but this levels off quickly.
 It would be a good idea to run a heap analyzer tool to see what kind of ob=
jects are being leaked; that might give us a clue as to what=92s happening.=
<u></u><u></u></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u>=A0<u></u></span><=
/p>
<p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:&quot=
;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href=
=3D"mailto:[email protected]" target=3D"_blank">owner-jess-users@=
sandia.gov</a> [mailto:<a href=3D"mailto:[email protected]" targe=
t=3D"_blank">[email protected]</a>]
<b>On Behalf Of </b>Daniel Selva<br>
<b>Sent:</b> Thursday, June 27, 2013 12:53 PM<br>
<b>To:</b> jess-users<br>
<b>Subject:</b> JESS: [EXTERNAL] Question on QueryResult close() function<u=
></u><u></u></span></p>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
<div>
<p class=3D"MsoNormal">Hi,<u></u><u></u></p>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">I am experiencing a memory leak problem in a Matlab-=
Jess application and I am trying to locate the leak. I came across the defi=
nition of the close() method of the QueryResult class. I have never called =
this method after using queries.=A0<u></u><u></u></p>

</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">1) Should I call close() after using a query?<u></u>=
<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">2) Could not calling close() be the cause of the lea=
k?=A0<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">If not, I would appreciate any tips on typical cause=
s of leaks in Matlab-Jess applications.=A0<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><u></u>=A0<u></u></p>
</div>
<div>
<p class=3D"MsoNormal">Thanks in advance,<u></u><u></u></p>
</div>
<div>
<p class=3D"MsoNormal"><br>
Daniel<u></u><u></u></p>
</div>
</div>
</div>
</div>

</blockquote></div><br></div>

--bcaec501638b50a3f004e037542e--