PDA

View Full Version : Windows Focus Switch Problem



Nickademus
July 11th, 2016, 23:07
When running FG in Windows, I'm noticing some unusual behavior. The best I can tell, when switching from FG to another window and back multiple times, FG takes up more and more memory and starts failing to respond for a short pause, then a long pause, and then an increasingly longer pause.

I know that FG checks the /images and /tokens folders for changes each time FG gains focus. Could it be there is a memory leak somewhere that is causing FG to duplicate the images and tokens in memory and thus taking longer and longer to check all the assets each time it gains focus?

Also, what's the feasibility of switching this check to manually controlled by a button on the Images frame and Token box or a radial menu option like the modules? I doubt people are adding assets each time they tab out to the internet or a text file or whatever. I know I rarely need it to refresh the lists.

darrenan
July 11th, 2016, 23:37
Can you verify your memory theory by watching process memory in TaskManager as you switch back and forth? If you can actually demonstrate a memory leak, that would be pretty compelling evidence.

LordEntrails
July 12th, 2016, 02:33
Point of reference, I can't duplicate what i think you may be seeing on my system.
Running FG full screen, have a single campaign open (1.397GB), using alt-tab to switch to other windows and coming back. Task Manager shows no change in used memory/process size.

Nickademus
July 12th, 2016, 02:52
Very well. Haven't been able to test since I have other things running that use memory.

So it's not a memory leak. I wonder why FG bogs down on switching. Restarting FG fixes it for a time, though the amount of time seems to vary.

LordEntrails
July 12th, 2016, 03:16
It could be a memory leak on your system. Just because it doesn't on mine doesn't prove its not your problem :) When you get a chance to test more, let us know and we'll see how we can confuse, err, I mean help you!

lesliev
July 12th, 2016, 03:48
Why not check the CPU usage instead of the memory? It's possible switching causes duplicate event handlers to be created which cause slow-downs but don't take any significant amount of memory.

Nickademus
July 12th, 2016, 04:18
I'm not really sure what I'm looking for with the CPU. It increases each switch, but goes back to zero for FG. That seems as expected.

It's really hard to isolate variables while working on things, but I did notice one thing that's consistent. I have a blank unnamed note that I made to hold data copy/pasted from other sources (hence a lot of the window switching). I don't use it all the time, but pull it up when I need to bring text into FG. Watching the Task Manager, I noticed that every time the empty blank note is opened, FG uses more memory. It never release this memory, either by closing the note or deleting it.

The amount isn't much (~400 KB) but I would think that the note shouldn't be using more and more memory when it isn't doing anything. I can literally open and close the note without adding any text and watch the memory usage for FG grow each time the note is opened.

Possibly one of the problems. Also, I feel I should note I'm on a 32-bit system, so FG is capped on memory at some point (but I'm pretty sure its higher than the 650 MB that it currently is running).

Moon Wizard
July 13th, 2016, 00:54
I can sort of see this on my machine, but the impact seems to be minimal.

One consideration is that Lua does garbage collection asynchronously, and every time a window is opened, then closed, several Lua objects are created then destroyed. Destroying a Lua object does not immediately free memory, until a garbage collection is performed.

I'm not quite sure if it's a memory leak or a garbage collection situation without spending a lot of time adding instrumentation to track it down.

Another thing to consider when switching is that having a lot of token files will slow it down, since it needs to retrieve and compare the list of token files each time. For the speed, you could try testing in a new campaign and remove any tokens files. If this adjusts the speed, then they could be separate items.

Regards,
JPG

Nickademus
July 13th, 2016, 04:23
With 39 MB of images and 1.3 MB of tokens, I don't think that's the issue. The garbage collection is more likely what I'm seeing.

Something that I did notice seemed to help was restarting my computer. It might just be a Windows thing.