[PyQt] Attempting to reduce the memory footprint of my PyQt5 application
Kovid Goyal
kovid at kovidgoyal.net
Thu Sep 15 16:39:45 BST 2016
I cannot reproduce via a timer either, script is:
import psutil
import subprocess
import time
import gc
import os
import threading
p = psutil.Process(os.getpid())
print(p.memory_info())
def f():
subprocess.check_output('true')
gc.collect(), gc.collect(), gc.collect()
print(p.memory_info())
threading.Timer(1, f, ()).start()
f()
input()
Output is:
pmem(rss=11374592, vms=58744832, shared=4669440, text=4096, lib=0, data=7122944, dirty=0)
pmem(rss=11931648, vms=58892288, shared=4993024, text=4096, lib=0, data=7270400, dirty=0)
pmem(rss=11960320, vms=134393856, shared=4993024, text=4096, lib=0, data=15794176, dirty=0)
pmem(rss=14303232, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
pmem(rss=12242944, vms=212086784, shared=5210112, text=4096, lib=0, data=24322048, dirty=0)
And before you ask, I verified that memory usage was constant using top
as well.
Kovid.
On Thu, Sep 15, 2016 at 06:11:02PM +1000, Xavion wrote:
> I've just updated the ticket <http://bugs.python.org/issue28165> I created
> on the Python bug tracker earlier. My most recent post lists the code
> fragment I'm using (i.e. via a timer, not a loop). The one before that
> details how I'm going about monitoring the memory (i.e. from a Bash script).
>
> I just incorporated your three "gc.collect()" calls and it made no
> difference. Starting the processes from the main event loop (rather than
> in a QThread) didn't help either. Everything was fine with the QThread
> anyway: disabling the process call kept the memory constant.
>
> I'll have a go at using Valgrind tomorrow.
>
> Thanks again for all of your help, guys.
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
_____________________________________
Dr. Kovid Goyal
http://www.kovidgoyal.net
http://calibre-ebook.com
_____________________________________
More information about the PyQt
mailing list