asmagill / hs._asm.axuielement

Accessing Accessibility Objects with Hammerspoon
34 stars 2 forks source link

hs._asm.axuielement - Excessive Memory Usage? #12

Closed latenitefilms closed 4 years ago

latenitefilms commented 5 years ago

@asmagill - As discussed in Hammerspoon #1980, I've started to have a play with lua-mtrace which looks really handy.

In the test logs it generated, I've noticed there's a billion lines that all reference the same line of code:

@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x60001e430100 0x38 t
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efb0f0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600003caab80 0x10 ?
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efb240 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x600003caab80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60000bf338e0 0x20
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efaf10 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60000bf338e0
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60001e430080 0x40
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efb150 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efacd0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60001e430080
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60002109b200 0x80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efbf60 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efbf00 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efb8a0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efae80 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60002109b200
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x600008377000 0x100
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x60001ebca180 0x38 t
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee7ab0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600003c42a10 0x10 ?
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee7a20 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x600003c42a10
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60000bece6c0 0x20
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee7a80 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60000bece6c0
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60001ebca1c0 0x40
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee7780 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee76f0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60001ebca1c0
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x600021097480 0x80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee7750 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee7720 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee6fd0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee6fa0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x600021097480
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x600008309500 0x100
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x60001ebceb80 0x38 t
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef07b0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600003c0f300 0x10 ?
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef2d30 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x600003c0f300
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60000bf35fa0 0x20
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef3ea0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60000bf35fa0
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60001ebcebc0 0x40
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef0330 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef0570 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60001ebcebc0
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60002109d100 0x80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef06f0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef0ba0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef1620 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef1110 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60002109d100
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x600008378b00 0x100
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x60001e430080 0x38 t
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002efa1c0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600003caab80 0x10 ?
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9680 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x600003caab80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60000bf30840 0x20
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9080 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60000bf30840
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60001e430040 0x40
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9050 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8f90 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60001e430040
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60002109b200 0x80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8ff0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8fc0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8f60 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8f30 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60002109b200
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x600008377100 0x100
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x60001e430040 0x38 t
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9e90 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600003caab80 0x10 ?
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9e60 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x600003caab80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60000bf30060 0x20
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9dd0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60000bf30060
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60001e4301c0 0x40
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9e30 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef9980 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60001e4301c0
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x60002109b200 0x80
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8060 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef85d0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef8540 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ef85a0 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 < 0x60002109b200
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 > 0x600008377200 0x100
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x60001ebca1c0 0x38 t
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee5e30 0x30 u
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600003c42a10 0x10 ?
@ .../CommandPost/src/extensions/hs/_asm/axuielement/init.lua:280 + 0x600002ee5dd0 0x30 u

Specifically:

local children = objectMT.attributeValue(self, "AXChildren")

If you get a chance, are you able to have a quick look at this code and see if you notice any obvious potential issues?

Thanks heaps!

asmagill commented 5 years ago

I want to see if I can block out a few days this month to go over a lot of the things I've been neglecting re Hammerspoon (though I'm glad to see that there is still healthy activity amongst new and old members going on in my absence!) and this will be on the list... it will probably be sometime next week or so once travel plans etc get ironed out.

Does the link you provided to lua-mtrace explain what the codes mean (e.g. +, <, t, etc.)?

latenitefilms commented 5 years ago

lua-mtrace instructions can be found here: https://www.zash.se/lua-mtrace.html

Thanks, as always for EVERYTHING! I HUGELY appreciate all the hard work, love and attention you put towards Hammerspoon.

asmagill commented 4 years ago

I'll add this to my things to do when I review this module this weekend.

asmagill commented 4 years ago

I never did get a chance to play with mtrace and there have been enough changes that I have no idea what line 280 used to be... is this still a concern? If so, reopen and I'll check out mtrace in the next day or so and see what I can find.

latenitefilms commented 4 years ago

There's still a memory leak SOMEWHERE in CommandPost, where in certain situations suddenly it will have taken over all of your RAM. It normally seems to happen if after a few days of use, when you're putting your machine to sleep each night, but leaving CommandPost running. We've never been able to nail down exactly where the issue lies sadly. It's one of those things that I'm hoping to eventually find.