Alright, it was a couple of days ago since I last had a look on this and it turns out that issue described in my first mail still persists. Although I had a typo. Swap 4 with 3 on the reference count. Also, when Im using PyImport_Import() directly it also shows 2 reference counts?<div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font><br><div class="gmail_quote">On Tue, Oct 26, 2010 at 11:29 PM, Simon W <span dir="ltr"><<a href="mailto:simwarg@gmail.com">simwarg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Of course, I did find another reference that I didn't notice. Python reference works as expected .. hehe!<div><div>
</div><div class="h5"><br><br><div class="gmail_quote">On Mon, Oct 25, 2010 at 7:35 PM, Simon W <span dir="ltr"><<a href="mailto:simwarg@gmail.com" target="_blank">simwarg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Hey again,<br><br>I'm trying to implement a load / unload module functionallity. When I delete the module in the __main__ dict the module's reference count is still > 1. I've been trying to find if I reference it anywhere else in my code but I can't find anything! When I did a check in vc++ debugger found something. When I run this code:<br>
<br>object obj = import(name.c_str()); <br><br><i>obj</i>'s <i>ob_refcnt</i> member is 2 when I check in the vc++ debugger. Shouldn't it be 1?<br><br>After that line, I put it in the __main__ dict like:<br>
<br>mMainNamespace[ name.c_str() ] = obj;<br><br>The reference count shows 4, as expected.<br><br>When I'm entering my unload() function when I want to remove the module I do like:<br>void unload()<br>{<br> object t = mMainNamespace[ name.c_str() ];<br>
// reference count in t is now 4 ?<br><br> mMainNamespace[ name.c_str() ].del(); // I delete but it's not unloaded properly because it's still referenced somewhere ..<br>}<br><br>What does import() do? It must save some reference somewhere?<br>
<br>
</blockquote></div><br>
</div></div></blockquote></div><br></div></div>