Results 1 to 3 of 3

Thread: About QLocalSocket problem

  1. #1
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Cool About QLocalSocket problem

    Below is my test code.I found clent applition memory leak.If I use QTcpSocket,the memory is normal.Is the problem the QT bug?

    QLocalSocket ls;
    ls.connectToServer("test");

    int i = 0;

    while (ls.waitForConnected())
    {
    QString message = QString::number(i) + "TTTTTTTTTT";

    ls.write( message.toStdString().c_str(), message.length());

    ls.flush();

    ls.waitForBytesWritten();

    Sleep(20);

    i++;
    }
    Last edited by wojiaoguowei; 6th August 2015 at 08:56.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: About QLocalSocket problem

    Are you sure you are leaking memory?
    I.e. make sure you are not just seeing an increase use in memory because the data is still buffered and not read by the other side.

    Also you should already think about encoding when converting the QString into an 8-Bit representation.
    When the string contains any non-ASCII character, the 8-Bit representation could be longer than the QString representation, so data and length should be derived from the same input.

    Cheers,
    _

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

    wojiaoguowei (7th August 2015)

  4. #3
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About QLocalSocket problem

    Thanks for advance.But if I change to use QTcpServer and QTcpSocket,the memory leak is gone.Now I have used QTcpSocket.Everything is ok.

Similar Threads

  1. QtService and QLocalSocket
    By matteo.ceruti in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2014, 18:45
  2. emit error for QLocalSocket
    By raj_iv in forum Qt Programming
    Replies: 2
    Last Post: 31st August 2011, 11:14
  3. QLocalSocket Synchronicity
    By matic in forum Qt Programming
    Replies: 0
    Last Post: 25th March 2010, 12:04
  4. Using QLocalServer and QLocalSocket
    By danc81 in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 12:09
  5. IPC with QLocalServer/QLocalSocket
    By ManuMies in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 20:09

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.