Thank you Markus.
That was helpful.

Kind regards,
Djordje Spasic 

      From: Markus Schaber <m.scha...@codesys.com>
 To: Djordje Spasic <issworld2...@yahoo.com> 
Cc: Discussion of IronPython <ironpython-users@python.org>
 Sent: Tuesday, December 22, 2015 11:04 AM
 Subject: RE: [Ironpython-users] Delete a large object in ironpython, and 
releasing the memory?
   
#yiv9528227099 #yiv9528227099 -- _filtered #yiv9528227099 
{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv9528227099 
{font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered #yiv9528227099 
{font-family:Verdana;panose-1:2 11 6 4 3 5 4 4 2 4;}#yiv9528227099 
#yiv9528227099 p.yiv9528227099MsoNormal, #yiv9528227099 
li.yiv9528227099MsoNormal, #yiv9528227099 div.yiv9528227099MsoNormal 
{margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;}#yiv9528227099 a:link, 
#yiv9528227099 span.yiv9528227099MsoHyperlink 
{color:blue;text-decoration:underline;}#yiv9528227099 a:visited, #yiv9528227099 
span.yiv9528227099MsoHyperlinkFollowed 
{color:purple;text-decoration:underline;}#yiv9528227099 
span.yiv9528227099E-MailFormatvorlage17 
{color:windowtext;font-weight:normal;font-style:normal;}#yiv9528227099 
.yiv9528227099MsoChpDefault {font-size:10.0pt;} _filtered #yiv9528227099 
{margin:70.85pt 70.85pt 2.0cm 70.85pt;}#yiv9528227099 
div.yiv9528227099WordSection1 {}#yiv9528227099 Hi,    IronPython runs on .NET 
which has a very different garbage collector than the one used in cPython.    
cPython uses reference counting, and a synchronous collector which collects 
cyclic garbage. Thus, objects which are not parts of cycles are guaranteed to 
be collected in the very moment when the last reference to them is removed, and 
the “del” statement is one way this could happen. (Just setting the variable 
reference None or some other object, or the variable dropping out of scope are 
some other possibilities.) However, collection of cyclic garbage happens 
somewhere later, depending on the thresholds of newly allocated objects. 
(Seehttps://docs.python.org/2/library/gc.html).    IronPython uses the .NET 
garbage collector which does not employ reference counting (at least not in 
Microsoft .NET, Mono and Rotor). Garbage collection always happens at a 
non-deterministic time – usually triggered by the “memory pressure” of the 
current process, which is mostly related to the amount of allocated memory over 
time.    In both cases, gc.collect() forces a complete garbage collection to 
occur now. (Actually, gc.collect() on IronPython mainly calls to 
System.GC.Collect() for this purpose, apart from performing some IronPython 
specific cleanups.)    Usually, there is no need to actively call the garbage 
collector – however, if you really have several hundred MBs of Memory which you 
want to release back to the OS immediately, I think it is justified to call the 
garbage collector. Especially if your process will not allocate any memory 
soon, the GC might not kick in for a long time if you don’t call it explicitly. 
   However, I want to emphasize that this is a special case, and generally, 
“normal” applications do not need to call the garbage collector explicitly, and 
should not (as frequent calls to the GC will impact performance negatively).    
   Best regards

Markus Schaber

CODESYS®a trademark of 3S-Smart Software Solutions GmbH

Inspiring Automation Solutions 3S-Smart Software Solutions GmbH
Dipl.-Inf. Markus Schaber | Product Development Core Technology 
Memminger Str. 151 | 87439 Kempten | Germany 
Tel. +49-831-54031-979 | Fax +49-831-54031-50 

E-Mail: m.scha...@codesys.com | Web: codesys.com | CODESYS store: 
store.codesys.com
CODESYS forum: forum.codesys.com

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade 
register: Kempten HRB 6186 | Tax ID No.: DE 167014915 This e-mail may contain 
confidential and/or privileged information. If you are not the intended 
recipient (or have received
this e-mail in error) please notify the sender immediately and destroy this 
e-mail. Any unauthorised copying, disclosure
or distribution of the material in this e-mail is strictly forbidden. From: 
Ironpython-users 
[mailto:ironpython-users-bounces+m.schaber=codesys....@python.org]On Behalf Of 
Djordje Spasic via Ironpython-users
Sent: Monday, December 21, 2015 5:19 PM
To: ironpython-users@python.org
Subject: [Ironpython-users] Delete a large object in ironpython, and releasing 
the memory?    I am a creating a huge mesh object (some 900 megabytes in size) 
in Rhino3d application by using its ironpython 2.7 interpreter. Once I am done 
with analysing this mesh, I would like to somehow delete it from the memory.

I did a bit of search on stackoverflow.com, and I found out that "del" 
statement will only delete the reference to mentioned mesh. Not the mesh object 
itself.
And that after some time, the mesh object will eventually get garbage 
collected. At least this is what some users on stackoverflow say about the 
regular cpython.

Is "gc.collect()" the only way by which I could instantly release the memory, 
and there for somehow remove the mentioned large mesh from the memory?
I've also found replies on stackoverflow.com which state that "gc.collect()" 
should be avoided (at least when it comes to regular python, not specifically 
ironpython).
I've also find comments on stackoverflow which claim that in IronPython it is 
not even guaranteed the memory will be released if nothing else is holding a 
reference.

Any comments on all these issues?

Is it even possible to instantly free the memory from the deleted large object 
in ironpython (2.7)?

Thank you for the reply.

Kind regards,
Djordje Spasic    

  
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
https://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to