Results 1 to 3 of 3

Thread: XORG using a lot of CPU resources

  1. #1
    Join Date
    Jun 2008
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default XORG using a lot of CPU resources

    Hello Folks,

    I am having a performance problem.

    The application I'm working on was fine until I put a timer to call
    update() of QLabel every 300ms.

    Every time I run my application the initial CPU usage of it is about
    60% - 70% and Xorg CPU usage is about 20% - 30% but that is normal.
    When the timer starts to call update of QLabel, the Xorg CPU usage
    starts increasing and reach almost 100% of CPU in 10 minutes and the
    CPU usage of my application falls to 4% - 5%. That happens when I use
    default graphics system (that would be the native??). When I run my
    app using "-graphicssystem raster" the problem disapears. Using
    "-graphicssystem opengl" crashes the system.

    OS : Ubuntu 9.04 (linux kernel 2.6.28-15-generic)
    Qt: 4.6.2
    X.Org X Server: 1.6.0
    GPU: GeForce 7300 SE/7200 GS
    NVIDIA Driver Version: 180.44

    I need to know what is going on here. Any help will be appreciated.

    Regards,
    Eduardo Luz

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: XORG using a lot of CPU resources

    Quote Originally Posted by eduluz View Post
    The application I'm working on was fine until I put a timer to call
    update() of QLabel every 300ms.
    What does the update do? Or, what are you painting on the label?
    Can you show some code? Maybe some parts can be performed more efficiently

  3. #3
    Join Date
    Jun 2008
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: XORG using a lot of CPU resources

    The timer calls that code :

    Qt Code:
    1. void CMessageLabel::checkAlarmDutyCycle( )
    2. {
    3. if(m_currentMsg.message().isNull()) {
    4. clear();
    5. update();
    6. m_alarmDutyOn = false;
    7. }
    8. else {
    9. if(m_currentMsg.state() == SILENCED){
    10. m_alarmDutyOn = true;
    11. update();
    12. }
    13. else {
    14. if(m_currentMsg.priority() == Monitoring::HIGH_PRIORITY) {
    15. m_alarmDutyOn = !m_alarmDutyOn;
    16. update();
    17. }
    18. else if(m_currentMsg.priority() == Monitoring::MEDIUM_PRIORITY) {
    19. m_alarmDutyOn = !m_alarmDutyOn;
    20. update();
    21. }
    22. else if(m_currentMsg.priority() == Monitoring::LOW_PRIORITY) {
    23. m_alarmDutyOn = true;
    24. update();
    25. }
    26. }
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    and my paint event is overwrited to change the background color of the Qlabel :

    Qt Code:
    1. void CMessageLabel::paintEvent(QPaintEvent* e)
    2. {
    3. QPainter painter(this);
    4. QRect rect = this->rect();
    5.  
    6. // define fundo do display
    7. if( m_currentMsg.message().isNull() ) {
    8. // sem fundo
    9. }
    10. else if(m_currentMsg.priority() == Monitoring::HIGH_PRIORITY) {
    11. // cor de fundo vermelha - frequência 1.5Hz duty cycle = 50%
    12.  
    13. qDebug("checkAlarmDutyCycle:HIGH_PRIORITY");
    14.  
    15. if(m_alarmDutyOn) {
    16. // Alterna a cor da fonte para melhorar visibilidade
    17. QPalette palette = this->palette();
    18. palette.setColor(QPalette::WindowText,QColor(0,0,0));
    19. setPalette(palette);
    20.  
    21. if(m_currentMsg.state() != SILENCED) {
    22. painter.setBrush(QBrush(QColor("#ff0000"), Qt::SolidPattern));
    23. painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
    24. }
    25. else {
    26. painter.setBrush(QBrush(QColor("#880000"), Qt::SolidPattern));
    27. painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
    28. }
    29. }
    30. else {
    31. // não preenche o fundo
    32.  
    33. // Alterna a cor da fonte para melhorar visibilidade
    34. QPalette palette = this->palette();
    35. palette.setColor(QPalette::WindowText,QColor(255,255,255));
    36. setPalette(palette);
    37. }
    38. }
    39. else if(m_currentMsg.priority() == Monitoring::MEDIUM_PRIORITY) {
    40. // cor de fundo amarela - frequência 0.5Hz duty cycle = 50%
    41. if(m_alarmDutyOn) {
    42. // alterna cor da fonte para melhorar visibilidade
    43. QPalette palette = this->palette();
    44. palette.setColor(QPalette::WindowText,QColor(0,0,0));
    45. setPalette(palette);
    46.  
    47. if(m_currentMsg.state() != SILENCED) {
    48. painter.setBrush(QBrush(QColor("#dddd00"), Qt::SolidPattern));
    49. painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
    50. }
    51. else {
    52. painter.setBrush(QBrush(QColor("#888800"), Qt::SolidPattern));
    53. painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
    54. }
    55. }
    56. else {
    57. // não preenche o fundo
    58. // Alterna a cor da fonte para melhorar visibilidade
    59. QPalette palette = this->palette();
    60. palette.setColor(QPalette::WindowText,QColor(255,255,255));
    61. setPalette(palette);
    62. }
    63. }
    64. else if(m_currentMsg.priority() == Monitoring::LOW_PRIORITY) {
    65. if(m_currentMsg.state() != SILENCED) {
    66. // cor de fundo ciano - constante
    67. painter.setBrush(QBrush(QColor("#00ffff"), Qt::SolidPattern));
    68. painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
    69. }
    70. else {
    71. // cor de fundo ciano - constante
    72. painter.setBrush(QBrush(QColor("#008888"), Qt::SolidPattern));
    73. painter.drawRect(rect.left(),rect.top(),rect.width(),rect.height());
    74. }
    75. }
    76.  
    77. // executa o método da classe base
    78. QLabel::paintEvent(e);
    79. // QWidget::paintEvent(e);
    80.  
    81. }
    To copy to clipboard, switch view to plain text mode 

    Regards,

Similar Threads

  1. Is it possible to add QT resources to a DLL?
    By cboles in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2017, 00:12
  2. PyQt4 app : high CPU usage from python and Xorg
    By tipote in forum Qt Programming
    Replies: 3
    Last Post: 30th January 2012, 17:50
  3. Qt Resources
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 3rd October 2008, 16:30
  4. QT application with opengl drops xorg session
    By YuriyRusinov in forum Qt Programming
    Replies: 1
    Last Post: 8th June 2008, 00:30
  5. Qt without X11/xorg? Framebuffer?
    By stodge in forum Newbie
    Replies: 4
    Last Post: 12th April 2007, 17:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.