Thanks, Thomas. Ill try kill-pointed...

On 2/17/10, Thomas Paviot <tpav...@gmail.com> wrote:
> 2010/2/18 Frank Conradie <fr...@qfin.net>
>
>> Hi guys,
>>
>
> Hi Franck,
>
>
>>
>> After running into serious memory use issues with our geometric
>> processing algorithm, I have done a simple experiment that seems to show
>> that wrapper garbage collection does not work at all. Try the code
>> below, and you should run out of memory in no time:
>>
>>
>> import gc
>> from OCC.gp import *
>> from OCC.BRepPrimAPI import *
>> from OCC.TopExp import *
>>
>> def TestMemory():
>>     w = 0.1
>>     fp1 = (0.,0.,0.)
>>     fp2 = (w,w,w)
>>     mkbox = BRepPrimAPI_MakeBox(gp_Pnt(fp1[0],fp1[1],fp1[2]),
>> gp_Pnt(fp2[0],fp2[1],fp2[2]))
>>     s1 = mkbox.Shell()
>>     e = TopExp_Explorer()
>>     for i in range(1000000):
>>         print i
>>         e.Init(s1, TopAbs_FACE)
>>         while e.More():
>>             sh = e.Current()
>>             e.Next()
>>         if not (i % 1000):
>>             print 'Collecting garbage...'
>>             gc.collect()
>>     while 1:
>>         pass
>>
>>
>> Not sure if this is a known issue or not,
>
>
> It's known to be an issue, see:
> * http://www.opencascade.org/org/forum/thread_17702/
> * the changelog of the 0.4 release
>
>
>> but it certainly makes the
>> wrapper problematic for our current purposes. If you can point me at the
>> right place in the wrapper generator I can maybe try and help.
>>
>
> The standard python gc module can not be used with pythonOCC: it's perfectly
> suitable to manage python objects deletion, but fails to properly handle the
> C++ pointed objects. A GarbageCollector class is available from any
> pythonOCC module you're using. For instance:
>
> Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51)
> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from OCC.Standard import *
>>>> GarbageCollector
> <module 'OCC.GarbageCollector' from
> '/Library/Python/2.6/site-packages/OCC/GarbageCollector.pyc'>
>>>> dir(GarbageCollector)
> ['GarbageCollector', '__builtins__', '__doc__', '__file__', '__name__',
> '__package__', 'garbage', 'sys']
>>>> GarbageCollector.garbage
> <OCC.GarbageCollector.GarbageCollector object at 0x100593e10>
>>>> dir(GarbageCollector.garbage)
> ['__class__', '__delattr__', '__dict__', '__doc__', '__format__',
> '__getattribute__', '__hash__', '__init__', '__module__', '__new__',
> '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',
> '__str__', '__subclasshook__', '__weakref__', '_collected_objects',
> 'collect_object', 'get_collected', 'purge']
>
> The source code of this module is here:
> http://svn.gna.org/viewcvs/pythonocc/trunk/src/wrapper/GarbageCollector.py?rev=706&view=markup
>
> In a few words, if you want to completely free memory:
> GarbageCollector.garbage.purge()
>
> If you want to free one specific object, use the _kill_pointed() method of
> that object (Nulify, Clear, Destroy won't work).
>
> I'll take time to write a more detailed message tomorrow about that topic.
>
>
>> Thanks,
>> Frank Conradie
>> Qfinsoft
>>
>
> All the best,
>
> Thomas
>

_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to