Results 1 to 2 of 2

Thread: Memory Problem with SIGNALS and SLOTS

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Memory Problem with SIGNALS and SLOTS

    Hi,

    I'm developing an image processing program that have to display the images from 4 cameras.

    I have a QWidget that opens a window (using functions provided by the camera manufacturer).

    I also have one Thread for each camera that is grabbing images and sending them to the main thread, when the main thread recives an image via SIGNAL/SLOT mechanism, itwill display the image.

    The problem is that if I use the 4 cameras, the memory consumption is growing because the main thread is getting very much images per second. The memory conumption will grow to the top of the memory of the system, then it crash.

    If I only use 2 cameras there is no problem.

    I have tryied to increase the main thread priority but nothing.

    I think that the main thread even loop is not able to destroy the images from the memory because it has not sufficient time.

    Is there anyway to force the main thread to destroy an image after I displayed it?

    Any one has any idea how to improve this?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Memory Problem with SIGNALS and SLOTS

    Store images to be displayed in some kind of shared buffer protected by a mutex. If the buffer already contains an image, overwrite it as it's already obsolete, even if it hasn't been displayed yet. Let the main thread periodically check buffers from each data source and display images which are currently in buffers. This should reduce memory usage and improve responsibility as the main thread won't be displaying old images. Remember about protecting the buffers with mutexes!

  3. The following user says thank you to wysota for this useful post:

    ^NyAw^ (19th March 2007)

Similar Threads

  1. Signals and Slots question
    By Thoosle in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2006, 00:24
  2. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  3. Problem with signals and slots
    By conexion2000 in forum Qt Programming
    Replies: 2
    Last Post: 23rd March 2006, 10:20
  4. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35
  5. Problem with Signal and Slots
    By Kapil in forum Installation and Deployment
    Replies: 2
    Last Post: 10th February 2006, 08:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.