I do something like

def maya_main_window():

     main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()

     return wrapInstance(long(main_window_ptr), QtGui.QWidget)


class TestTool(QtGui.QDialog):


def __init__(self, parent=maya_main_window()):

    super(TestTool, self).__init__(parent)

I´ll tomorrow at work  window.setAttribute(QtCore.Qt.WA_DeleteOnClose)

R
El martes, 25 de abril de 2017, 20:42:23 (UTC+1), Justin Israel escribió:
>
>
>
> On Wed, Apr 26, 2017, 4:17 AM Rudi Hammad <[email protected] 
> <javascript:>> wrote:
>
>> Hi,
>> I am using Pyside. I don´t use any globals. I open the ui with .show(). 
>> And I close with cmds.deleteUI() if the windows exists.
>> Not all the widgets are parented to the UI, because that UI have widgets 
>> like buttons that launch other smallet UIs.
>>
>
> Are toy parenting your top level window to the Maya Main window? It is a 
> common error that I see people doing, where they create windows that are 
> parented to Maya and then let the reference go. When users close them, they 
> remain alive. 
>
> You could tell your top level window to delete itself when a user closed it
>
> window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
>
> But you did say you are deleting previous instances when you launch a new 
> one, and garbage still continues to increase? That would imply you have 
> something holding onto references and/or your delete is not finding the 
> previous window as you expect. 
>
>
>
>> R
>>
>>
>> El martes, 25 de abril de 2017, 14:53:59 (UTC+1), thirstydevil escribió:
>>
>>> You shouldn't need to gc.collect() in python.  When the instances 
>>> reference count goes to 0 then at some point in the future pythons garbage 
>>> collection will kick in.  If you are holding onto references then this 
>>> could account for the memory bloat.  But if you are patient you might also 
>>> see python clean up after itself.
>>>
>>> How are you building the UI?  PySide?  Are you using a lot of globals?  
>>> How are you closing and opening the UI?  Are you parenting all you widgets 
>>> into the UI?
>>>
>>> -Dave
>>>
>>>
>>> On Tue, Apr 25, 2017 at 2:19 PM, Rudi Hammad <[email protected]> wrote:
>>>
>>>> Hello,
>>>> I am developing a rig builder tool for the studio that is quite heavy, 
>>>> and after running the UI I checked the garbage collection and I get a 
>>>> result of gc.collect() -->322. If I run the UI 3 times, then the 
>>>> gc.collect() -->955
>>>>
>>>> I don´t know much about memory performance so I wonder if  this 
>>>> happening because my code is not clean enough or if this normal while 
>>>> programming a code with a lot a variables and objects?
>>>> Should I just do gc.collect() at the end of the script to clean things 
>>>> up?
>>>>
>>>> thank you
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/python_inside_maya/9bc3d18a-5f39-44bf-948c-22c7d7746a86%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/python_inside_maya/9bc3d18a-5f39-44bf-948c-22c7d7746a86%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>>
>> *David Moulder*
>>> Technical Animator / Artist
>>>
>> [email protected]
>>> *Professional Profile 
>>> <http://uk.linkedin.com/pub/david-moulder/1/b12/b5a>*
>>>
>>> Mobile: +44 (0)7814033242
>>> See who we know in common 
>>> <http://www.linkedin.com/e/wwk/5748982/?hs=false&tok=3tztwkse1silw1> Want 
>>> a signature like this? 
>>> <http://www.linkedin.com/e/sig/5748982/?hs=false&tok=3pwLU9-mBsilw1>
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/818f6def-71a8-4b51-b40e-9860dd6db5e1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/818f6def-71a8-4b51-b40e-9860dd6db5e1%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/8f9ad9df-6236-41bb-828a-6aa85a2538b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to