Results 1 to 3 of 3

Thread: Writing to a file from within a QThread is causing the app to deplete system memory

  1. #1
    Join Date
    Apr 2014
    Posts
    34
    Thanks
    14
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Writing to a file from within a QThread is causing the app to deplete system memory

    I have a threaded application that reads data from a UDP socket in one thread, and then passes that data to two other threads: one for processing one for writing out to a file. (Note: The processing thread does nothing at the moment). All the writing thread does is write the data out to an open file.

    When I run the app, it constantly consumes memory and then swap space, until there is none left. The OS then terminates the application.

    I don't understand this behavior, can anyone shed any light on this? I've attached the entire source code in a tar file.


    PS: I also welcome any comment/critique on my use of QThreads.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Writing to a file from within a QThread is causing the app to deplete system memo

    It does not do that in my environment (Linux 64-bit, GCC 6, Qt 5.7.1). Built code as supplied. Does nothing other than create empty file until a UDP datagram is received. Using netcat sent the 519-byte PRO file as a datagram: 4000 bytes written to file. Repeated: 8000 bytes in file etc.

    Are you certain this program is the problem? Is the sender you are testing with also on this machine?

  3. #3
    Join Date
    Apr 2014
    Posts
    34
    Thanks
    14
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Writing to a file from within a QThread is causing the app to deplete system memo

    Quote Originally Posted by ChrisW67 View Post
    It does not do that in my environment (Linux 64-bit, GCC 6, Qt 5.7.1). Built code as supplied. Does nothing other than create empty file until a UDP datagram is received. Using netcat sent the 519-byte PRO file as a datagram: 4000 bytes written to file. Repeated: 8000 bytes in file etc.

    Are you certain this program is the problem? Is the sender you are testing with also on this machine?
    Sorry, I should have provided more detail...

    Yes, the sender I am testing with is also running on the same machine. I've attached the code for the sender I use. It's a small C application that generates UDP datagrams in a tight while loop. Note: This sender app is just for testing; in deployment of the main application, the data that it receives is generated on another machine and sent over UDP.

    I am running this on a RHEL7 laptop with:
    gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
    QMake version 3.0
    Using Qt version 5.5.1 in /opt/Qt5.5.1/5.5/gcc_64/lib


    I realize that writing out that much data could be problematic -- but I didn't expect it to cause the system to consume memory they way it does.
    Attached Files Attached Files

Similar Threads

  1. Qt Plugins causing memory problems?
    By gavinmagnus in forum Qt Programming
    Replies: 5
    Last Post: 2nd August 2017, 21:47
  2. Open an in-memory file with the default system application
    By berzasnon in forum Qt Programming
    Replies: 8
    Last Post: 7th October 2012, 18:03
  3. When I use Listview with icons its causing memory leak
    By GuusDavidson in forum Qt Programming
    Replies: 4
    Last Post: 29th March 2011, 23:08
  4. vector causing system error/crash
    By babygal in forum Newbie
    Replies: 9
    Last Post: 21st October 2010, 08:48
  5. QThread::wait() causing crash
    By Olliebrown in forum Qt Programming
    Replies: 3
    Last Post: 24th September 2010, 16:24

Tags for this Thread

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.