High CPU load due to repeated paint() calls


#1

Hi!
It seems that in my tool, the paint() funtion is recalled in a fast manner so that the CPU is in a high load state.
I tried to find the reason, but when I set a breakpoint, the call stack does’t say me much. Here is it (can somebody perhaps see something?)

>    KLANGapp.exe!RoutingGrid::paint(juce::Graphics & g={...}) Zeile 142    C++
     KLANGapp.exe!juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Zeile 1964    C++
     KLANGapp.exe!juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Zeile 2069    C++
     KLANGapp.exe!juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Zeile 1947    C++
     KLANGapp.exe!juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Zeile 2010    C++
     KLANGapp.exe!juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Zeile 2069    C++
     KLANGapp.exe!juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Zeile 1947    C++
     KLANGapp.exe!juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Zeile 2010    C++
     KLANGapp.exe!juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Zeile 2069    C++
     KLANGapp.exe!juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Zeile 1947    C++
     KLANGapp.exe!juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Zeile 2010    C++
     KLANGapp.exe!juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Zeile 2069    C++
     KLANGapp.exe!juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Zeile 1947    C++
     KLANGapp.exe!juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Zeile 2010    C++
     KLANGapp.exe!juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Zeile 2069    C++
     KLANGapp.exe!juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Zeile 1947    C++
     KLANGapp.exe!juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Zeile 2010    C++
     KLANGapp.exe!juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=true) Zeile 2069    C++
     KLANGapp.exe!juce::ComponentPeer::handlePaint(juce::LowLevelGraphicsContext & contextToPaintTo={...}) Zeile 160    C++
     KLANGapp.exe!juce::HWNDComponentPeer::performPaint(HDC__ * dc=0x6b010e57, HRGN__ * rgn=0x2404019f, int regionType=3, tagPAINTSTRUCT & paintStruct={...}) Zeile 1646    C++
     KLANGapp.exe!juce::HWNDComponentPeer::handlePaintMessage() Zeile 1541    C++
     KLANGapp.exe!juce::HWNDComponentPeer::peerWindowProc(HWND__ * h=0x0006068e, unsigned int message=15, unsigned int wParam=0, long lParam=0) Zeile 2406    C++
     KLANGapp.exe!juce::HWNDComponentPeer::windowProc(HWND__ * h=0x0006068e, unsigned int message=15, unsigned int wParam=0, long lParam=0) Zeile 2358    C++
     user32.dll!752b84f3()    Unbekannt
     [Unten angegebene Rahmen sind möglicherweise nicht korrekt und/oder fehlen, keine Symbole geladen für user32.dll]    
     user32.dll!75296c40()    Unbekannt
     user32.dll!75296820()    Unbekannt
     user32.dll!7529ddc6()    Unbekannt
     user32.dll!7529d169()    Unbekannt
     ntdll.dll!77278e56()    Unbekannt
     kernel32.dll!746138f4()    Unbekannt
     ntdll.dll!77265de3()    Unbekannt
     ntdll.dll!77265dae()    Unbekannt

Thanks!


#2

Breakpoints won’t tell you anything at all about performance - you need to profile your app to get metrics on where the time is being spent.


#3

I know where it is spent (I whink)… in the paint() routine. The question is, why it is called that often (that is why I wanted to see the trace)…


#4

I’ve profiled my app. But the only thing I can see, is an endless call history (functions whose name I don’t know)… hmmm


#5

deleted - it’s windows :slight_smile: do you call repaint in a paint method.