>> I'm developing a new cython class, and I currently have it print a message
>> to tell me when it gets deallocated.
>>
>> When I instantiate the class in a function, __dealloc__ gets called -- but
>> if I instantiate at the commandline and don't capture the reference, it's
>> lost but doesn't get garbage collected.
>
> It is a known issue that also happens if you create a matrix. I have no
> real insight what goes wrong, so if you figure this out let is know.

I'm starting to think this is a problem with IPython -- it isn't cython 
specific.  See code below.

>
>> sage: I = memoryPhage() #eats all memory available
>> sage: del I
>> dealloc!
>> sage: def foo():
>> ...       memoryPhage()
>> sage: foo()
>> dealloc!
>> sage: memoryPhage()
>> sage: memoryPhage()
>> ***crash and burn***
>
> Do you check if the allocated memory is still valid, i.e. add a NULL check
> before deallocating it? Can you post the code?

So, the crash and burn is a segfault that occurs because there isn't enough 
memory to allocate.  That's what happens in Cython, anyway -- Python seems to 
try to handle this "gracefully", and causes my entire system to hang -- this 
baffles me, since I don't have swap space.  Honestly, I'd prefer a segfault to 
just thrashing which requires a hard boot (or... who knows -- maybe it will 
come back in a "finite" amount of time -- I don't want to wait an hour)

sage: class memPhage():
    ...:     def __init__(self):
    ...:         self.v = range(5*10^7)
    ...:
sage: memPhage()
<__main__.memPhage instance at 0x9c62b0c>
sage: memPhage()
<__main__.memPhage instance at 0x9c62bcc>
sage: memPhage()

... and at this point, I have to restart my computer.  I should be able to do 
this a million times without a problem -- so it seems like we're missing a 
decref.



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to