<p dir="ltr">Your binaries are rather outdated..</p>
<p dir="ltr">Here is the latest branch:</p>
<p dir="ltr"><a href="https://github.com/pythonnet/pythonnet/tree/develop">https://github.com/pythonnet/pythonnet/tree/develop</a></p>
<p dir="ltr">And binaries here:</p>
<p dir="ltr"><a href="https://pypi.python.org/pypi/pythonnet/2.1.0.dev1">https://pypi.python.org/pypi/pythonnet/2.1.0.dev1</a></p>
<p dir="ltr"><a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonnet">http://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonnet</a><br>
</p>
<br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 18, 2016, 4:47 PM Eliana Mendes <<a href="mailto:eliana.mendesp@gmail.com">eliana.mendesp@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal">Hello Tony,</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Thanks a lot for your answer! I actually just got directly the
“Python.Runtime.dll”  from the download
link in sourceforge: <a href="http://sourceforge.net/projects/pythonnet/files/" target="_blank">http://sourceforge.net/projects/pythonnet/files/</a>.
But from the description I see that the last update of that one was done in
2013. Would there be a newer version somewhere else that I could get?  Perhaps this version I’m using is out of date
and you have a newer one. Let me know if that’s the case. </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I tried your suggestion of putting the “using” statement for
the tuple objects, and also for “myTuple”, and the memory is still increasing a
lot. I’ve made a memory profile to see which objects are being retained and
after I ran that statement 5 thousand times I got this:</p><p class="MsoNormal"><br></p><p class="MsoNormal"><img src="cid:ii_1525623d7d0b33a8" alt="Imagem inline 1" width="590" height="120" style="margin-right:0px"><br></p><p class="MsoNormal"><br></p>

<p class="MsoNormal">As you can see more that 12 thousand instances of “PyInt” and
more than 6 thousand of “PyObject” are created . Apparently it is creating
these “PyInt” and “PyObjects” somewhere inside the “AsManagedObject”, because I
don’t have PyInt objects anywhere in my code and this just happens when I call “AsManagedObject”.
</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Let me know if there is a newer version that could probably
have that problem fixed which I am not aware of. </p><p class="MsoNormal"><br></p>

<p class="MsoNormal">I appreciate a lot your help!</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Best regards,</p>

<p class="MsoNormal">Eliana</p></div><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2016-01-17 6:05 GMT-06:00 Tony Roberts <span dir="ltr"><<a href="mailto:tony@pyxll.com" target="_blank">tony@pyxll.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Eliana,<div><br></div><div>which version of pythonnet are you using? when you say you're using the latest are you building it yourself from the develop branch on github?</div><div><br></div><div>I had a quick look at the code that converts from a python object to a double, and I don't see any obvious memory leaks there. Perhaps the leak is the objects resulting from indexing into the tuple are never getting disposed? Try something like this instead and see if it helps (and report back as it may help improve the code if we know exactly what the problem is).</div><div><br>PyTuple myTuple = PyTuple.AsTuple(result);<div><br></div><div>double result0;<br>using (var item0 = myTuple[0])<br>    result0 = (double)item0.AsManagedObject(typeof(double));<br><br>double result1;<br>using (var item1 = myTuple[1])<br>    result1 = (double)item1.AsManagedObject(typeof(double));<br><br>myTuple.Dispose();<div><br></div><div>I would also use a using statement for the myTuple as well, just to be sure dispose is called in the case an exception is thrown somewhere.</div><div><br></div><div>Regards,</div><div>Tony</div></div></div><div><br></div></div><br><div class="gmail_quote"><div><div><div dir="ltr">On Fri, Jan 15, 2016 at 8:06 PM Eliana Mendes <<a href="mailto:eliana.mendesp@gmail.com" target="_blank">eliana.mendesp@gmail.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif;background-image:initial;background-repeat:initial">Hello
experts,</span><span style="font-size:12pt;font-family:'Times New Roman',serif"></span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif"> </span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">I'm having a memory
leak problem when using the function AsManagedObject(typeof(double)).
Basically I have something like this: </span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif"> </span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">PyTuple myTuple =
PyTuple.AsTuple(result);</span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">double result0 =
(double)myTuple[0].AsManagedObject(typeof(double));</span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">double result1 =
(double)myTuple[1].AsManagedObject(typeof(double));</span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">myTuple.Dispose();</span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif"> </span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">where
"result" is just a PyObject that returned from a python function. I
simplified the code above just so you can understand better, but the thing is
that the line that calls "AsManagedObject” 
is executed thousands of times and it is increasing significantly the
memory heap (it goes over 3 GB of memory in my scenario and it’s not released after
execution). If I don't call just this specific function the memory remains
stable. But I don’t know any other way to convert the PyObject to
"double" unless using the “AsManagedObject” function.</span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">It sounds to me that
some objects are allocated inside the "AsManagedObject" method and
they are not being released. Maybe it’s a bug there. Any ideas? I'm using latest version of python for .NET.</span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif"> </span></p>

<p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">Thank you!</span></p><p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif"><br></span></p><p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">Eliana Mendes</span></p><p class="MsoNormal"><span style="font-size:12pt;font-family:Arial,sans-serif">Software Engineer</span></p><div><br></div></div></div></div>
_________________________________________________<br>
Python.NET mailing list - <a href="mailto:PythonDotNet@python.org" target="_blank">PythonDotNet@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pythondotnet" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/pythondotnet</a></blockquote></div>
<br>_________________________________________________<br>
Python.NET mailing list - <a href="mailto:PythonDotNet@python.org" target="_blank">PythonDotNet@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pythondotnet" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/pythondotnet</a><br></blockquote></div><br></div></div>
_________________________________________________<br>
Python.NET mailing list - <a href="mailto:PythonDotNet@python.org" target="_blank">PythonDotNet@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/pythondotnet" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/pythondotnet</a></blockquote></div>