×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    178

    Unhappy QDataStream leaks memory?

    I'm logging my heap size like this:
    Code:
    // Heap size logging
    TInt used = 0;
    User::Heap().AllocSize(used);
    ...and it seems that QDataStream is leaking memory when I do data serialization.
    Code:
    // Externalize class to data
    const QByteArray& MyClass::externalize() const
    {
        // iData  QByteArray* has been initialized in constructor and deleted in destructor.
        QDataStream out(iData, QIODevice::Append);
        out << testString1;
        out << testString2;
        out << testBool;
        return *iData;
    }
    
    // Internalize data to class
    int MyClass::internalize(const QByteArray& aData)
    {
        QDataStream in(aData);
        if(in.atEnd())
        {
            return 0;
        }
        else
        {
            in >> *testString1;
            in >> *testString2;
            in >> *testBool;
            return in.device()->pos() ;
        }
    }
    __UHEAP_MARK and __UHEAP_MARK_END also panics. Is there are bug in Qt or does it leave some handles open to be deleted later? How can I verify that my code does not leak memory in Qt?

    I'm using Qt version 4.6.3.

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: QDataStream leaks memory?

    Hi,
    Check the pointer and the reference of the bytearray. They are not used correctly.

Similar Threads

  1. Memory leaks
    By edgar.alves in forum Symbian
    Replies: 9
    Last Post: 2009-03-10, 08:20
  2. Help my memory leaks
    By gigglie in forum Symbian
    Replies: 4
    Last Post: 2008-09-23, 20:50
  3. Memory leaks
    By francois_plancke in forum Symbian
    Replies: 2
    Last Post: 2005-02-28, 08:05
  4. Memory leaks
    By ManishPatil in forum Symbian
    Replies: 0
    Last Post: 2004-12-09, 11:55
  5. Memory Leaks
    By abhishekmishra in forum Symbian
    Replies: 1
    Last Post: 2002-08-21, 15:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×