Hi, Am 03.11.2014 um 22:21 schrieb Joren Heit: > I received a bug-report > <https://github.com/jorenheit/awesome_alttab/issues/5> on github the other > day of someone who's been having problems with my alt-tab implementation. > The preview-window that pops up is refreshed at some rate (e.g. 30fps) > calling cr:paint() each time for every widget to draw the window-contents > in a preview-box.
https://github.com/jorenheit/awesome_alttab/blob/master/init.lua#L151 local icon if c.icon == nil then icon = gears.surface(gears.surface.load(noicon)) else icon = gears.surface(c.icon) end First: gears.surface() and gears.surface.load() are the same function. Replace the above code with: local icon = gears.surface(c.icon or noicon) Second: The above change will also fix a memory leak. (Technical details below) However, I don't think that leaking icons is a big memory leak. Also, awesome doesn't copy the icon when returning it to lua, so this isn't the leak that we are looking for. Third: Urgh. So the following code begins at line 209: cr:translate(tx, ty) cr:scale(sx, sy) cr:set_source_surface(gears.surface(c.content), 0, 0) cr:paint() You don't want to know the details, but could you try this: local foo = gears.surface(c.content) cr:translate(tx, ty) cr:scale(sx, sy) cr:set_source_surface(foo, 0, 0) cr:paint() foo:finish() But the above should (could?) be fixed via the collectgarbage() calls which you already tried... Also, my proposed change is technically wrong and might break later. So let's see if it just helps in figuring out what's up. You might also want to check your lua-lgi version because of this bug: https://github.com/pavouk/lgi/issues/70 Cheers, Uli P.S.: Technical details: Lua uses garbage collection. You don't have to explicitely free stuff, it happens automagically for you. To free cairo surfaces, lua has to be told how these can actually be freed. Due to the way that lgi works, the C core cannot tell lua to do this. So accessing c.icon actually creates a memory leak. Then gears.surface() does some magic to wrap things up so that lua can free the surface properly. If you do "if c.icon == nil then", when the icon isn't actually nil, the reference that the C code gives to lua is leaked. So every call to c.icon really has to have its result passed to gears.surface(). -- "Because I'm in pain," he says. "That's the only way I get your attention." He picks up the box. "Don't worry, Katniss. It'll pass." He leaves before I can answer. -- To unsubscribe, send mail to [email protected].
