I run a stock analysis program with Wine. What it does is basically display the chart of a chosen stock. Above the chart, there is a menu bar that let you have some control like change time frame, or go back, etc. There also a right-click popup menu that let you have some other controls. What is strange is that when switching the mouse from the chart to the GUI, or vice versa, there is a huge memory and CPU usage upsurge. Memory surges from normally 40% total on the system to about 80% on my 4GB RAM machine. And one CPU (of the due core) usage surges to 100%. This lasts for about 7-8 seconds, as if something huge is being swapped in and out. After that it is back to normal. Of course, during upsurge time the program doesn't really respond. The question is why a switch of focus between graphics and GUI causes such a big resource hog. What can I do to find out more about what if going on or solve the problem? Any help would be greatly appreciated.
On Sun, 2009-11-08 at 21:16 -0600, cnbiz850 wrote:> The question is why a switch of focus between graphics and GUI causes > such a big resource hog. What can I do to find out more about what if > going on or solve the problem? Any help would be greatly appreciated. >First consider what your program is doing internally. Do you know: - What volume of stock data is your program holding? - Is that being swapped? - Does the program have any debugging/tracing facilities you can turn on? If that doesn't help, try the 'top' utility: - What does it show? - In particular, which processes are active during the change of focus? - What does it say about swap space usage? If none of the above show enough detail to work out what's going on, install the sysstat package. It should be an extra for your distro if it isn't already installed. Use it to get more details about what your program is doing in terms of memory usage, paging, etc. Martin
Thanks for the response. First of all, I need to say that the Windows program doesn't have this high resource usage phenomenon under Windows. It just happens under Wine.> If that doesn't help, try the 'top' utility: > - What does it show? > - In particular, which processes are active during the change of focus? > - What does it say about swap space usage? >"top" shows that this particular program (called special.exe) taking a lot of CPU and memory during change of focus as I mentioned originally. It doesn't use much swap space as my 4GB RAM is not depleted. I will try to use sysstat, but I am not to sure what to look for. I suspect more that it has to do with Wine's handling of GUI and graphics. Anyone please advise some specifics about it. Many thanks.
cnbiz850 wrote:> What is strange is that when switching the mouse from the chart to the GUI, or vice versa, there is a huge memory and CPU usage upsurge. Memory surges from normally 40% total on the system to about 80% on my 4GB RAM machine.What distro? What video card & drivers? Have you disabled 3d-desktop effects?
Thanks, Martin, for the detailed advice. I tried pidstat and feel that it tells me no more than the fact that the abnormal resource is taken by one of the 4 subprocesses of the program I am running with Wine. I know the problem comes from there, but I still don't know how is happening inside and how to find a fix. Played around with the program further and found something interesting. The abnormal resource usage is actually not due to a switch of focus between graphics and GUI. It is due to mouse movement in the graphics area under certain circumstances. The circumstances include having stock price moving average lines drawn on the chart, which was the default feature. Turning off the moving average lines or switch to certain other indicators can make the problem go away. I can not image what is going on. Why mouse moving with MA drawn sucks so much resource? Again this is not detected at all under Windows. Any good imagination please?
> Is there any detailed tracing you can turn on in the program that would > show what changes in mouse listener operation or usage when the moving > average lines option is on?That is something I also wonder. What can be the difference related to mouse listener between having the moving average lines and having certain other indicators? From the functionality point of view, there should be none. This is something I still can not figure out. I will try. Any suggestion is greatly appreciated.
cnbiz850 wrote:> What can be the difference related to mouse listener between having the moving average lines and having certain other indicators?Nothing is different. The only thing it could be is application mixing ddraw & GUI calls (to draw charts & text) which is extremely expensive on Wine. And when you moving mouse from chart area to other part of GUI it redraws the entire program, or big part of it. Try enabling +bitmap debug channel and see if something trying to create huge bitmap when memory usage spikes.