Hi,

Here is a simple example that consumes more and more memory. If my example
can be fixed to prevent this, please let me know.

Regards,

Marcel

On Sat, Apr 23, 2011 at 1:31 PM, Schnizer, Pierre Dr. <[email protected]>wrote:

>  Dear Marcel, deal all,
>
>    I had a look to the root of the problem last time. I will see to it
> again.
> Basically it is a problem in a inner loop when PyGSL is converting the
> arrays.
> The last problem Ling Li posted, was only getting in trouble for arrays of
> length 0.
> So I did not investigate it too much further as I was not aware that
> arrays of length zero could be of practical interest.
>
> When do you run into that trouble? Could you post a simple example?
>
> Sincerely yours
>   Pierre
>
>
> -----Ursprüngliche Nachricht-----
> Von: Marcel Tünnissen [mailto:[email protected] <[email protected]>]
> Gesendet: Sa 23.04.2011 07:42
> An: [email protected]
> Betreff: Re: [pygsl-discuss] Memory leak
>
>
> Hi,
>
> I seem to have a similar problem as Ling Li but then with the
> multiroots. Any news on this subject? Any workaround, like in the way
> of handling the exception in my code? Or should I perhaps open an bug
> report?
>
> Marcel
>
> Ling Li wore:
> ---------------------------------------------------------------------
>
> I found a memory leak when exception happens.  I was using pygsl 0.95
> and gsl 1.13 on Fedora 12, but switching to gsl 1.14 (from Fedora
> rawhide) gave the same memory leak problem.
>
> Here's a test Python code (I am using blas.dtrmv as an example,
> although the memory leak happens to many other functions I've tried):
>
> ============
> from pygsl import blas
> import numpy
> import sys
>
> def test_pygsl_memory_leak():
>     n = 2000
>     A = numpy.zeros([n, n], order='F')  # to trigger a sanity check in gsl
>     b = numpy.zeros(n)
>     print sys.getrefcount(A), sys.getrefcount(b)
>     try:
>         l = blas.dtrmv(A[:0, :0], b[:0])
>     except Exception as e:
>         print e
>     print sys.getrefcount(A), sys.getrefcount(b)
> ============
>
> And the output:
>
> ============
> $ python
> Python 2.6.2 (r262:71600, Jun  4 2010, 18:28:58)
> [GCC 4.4.3 20100127 (Red Hat 4.4.3-4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from memory import test_pygsl_memory_leak
> >>> test_pygsl_memory_leak()
> 2 2
> sanity check failed - shouldn't happen: Stride not one of a contiguous
> array!
> 3 3
> ============
>
> If one runs it many many times in an interpreter, you will see the
> memory usage goes up pretty quickly.
>
> Thanks.
>
>
#!/usr/bin/python
import pygsl
from pygsl  import multiroots, errno

def func(c, params):
    return [2]

class Method:
    hybrids = 0
    dnewton = 1
    broyden = 2
    hybrid  = 3

def FindMultiRoot(
    initialValues
):
    nrOfIns = len(initialValues)
    maxIter = 64
    precision = 1e-15
    method = Method.hybrids

    mysys = multiroots.gsl_multiroot_function(func, [], nrOfIns)
    solver = multiroots.hybrids(mysys, nrOfIns)
    solver.set(initialValues)
    result = None
    for iter in range(maxIter):
        status = solver.iterate()
        x = solver.getx()
        f = solver.getf()
        status = multiroots.test_residual(f, precision)
	if status == errno.GSL_SUCCESS:
	    result = x[:]
	    break
    return result

while True:
    try:
	result = FindMultiRoot([1])
	if result != None:
	    print 'result:', result
    except pygsl.errors.gsl_SingularityError:
	# break
	pass
    except pygsl.errors.gsl_NoProgressError:
	# break
	pass
    except pygsl.errors.gsl_JacobianEvaluationError:
	# break
	pass
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
pygsl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pygsl-discuss

Reply via email to