Results 1 to 11 of 11

Thread: Memory Leak Issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Memory Leak Issue

    Quote Originally Posted by linuxdev View Post
    My requirement is to have,
    N different arrays capable to hold at-most 50 items, for each key.
    That's not enough information to decide. If you insert an item. Where will you insert? Always at the end/front. In the middle? And when you want access an item. Where is that item? Front/back/middle? Different, or always the same location?

  2. #2
    Join Date
    Dec 2008
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Memory Leak Issue

    Sorry for not providing the information at first.


    Here is complete detail:

    a. The data is received from network at continuos intervals
    b. The data has an unique Id/key associated with it.
    c. For each key i receive, next data/update in a interval of 3secs.
    d. I need to store a maximum of 50 updates for each data, and many such data and the data is always stored sequentially.
    e. i just access these data only sequentially.
    f. There can be atmost 200 such unique data in my application at any point of time.
    g. i need to do an efficient search based on the Unique ID.

    If you need more information, i am working on Radar Display Software, and data called Track data (Detections) is recevied from radar at specific intervals, say 3secs.

    Each Track has an ID/Key associated with it and there can be atmost 200 Tracks and any point of time in the application and hence in my display and database.

    for each Track, i need to store trial information, this is nothing but the history for a particular track. This data is just stored sequentially.

    My current design is,
    I have an QHash, which has TrackId as key and pointer to QVector as Value.
    Each time i receive a new track, i create a new QVector and append the new track data as the first element and on every update i just append to the end.

    When a data for already existing key is received, i just append to the end of QVector which already exists.

    You can get more information from the function, "track+dbase" i have posted earlier.

    Hope you find this useful...

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Memory Leak Issue

    Ok, QHash is the best for providing fast lookups and if you don't need the maximum 200 items to be ordered, perfect.

    The point with QVector is, that it stores all items in adjacent positions in memory. So to avoid much coping use QVector::reserve(). But then you need a "lot" of space. Don't know how much is available (embedded?). If I haven't make a mistake while counting 200 keys with 50 items is only about 5 MB of disk space, so I think you can keep your QVector.
    But if you store pointers to the items TTrack, then I would take a QList.

    Qt Code:
    1. QHash<int, QList<TTrack*> > foo; //first choise
    2. QHash<int, QVector<TTrack> > bar; //second choise
    To copy to clipboard, switch view to plain text mode 

    And if you need to store pointers to the vector, don't forget delete on it when removing a key from QHash...

  4. #4
    Join Date
    Dec 2008
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Memory Leak Issue

    Thanks i have taken second choice ...

Similar Threads

  1. Memory leak detection
    By Sid in forum Qt Programming
    Replies: 8
    Last Post: 4th May 2011, 22:38
  2. memory leak question
    By cool_qt in forum General Programming
    Replies: 3
    Last Post: 20th January 2009, 07:49
  3. Memory leak weirdness
    By Darhuuk in forum General Programming
    Replies: 10
    Last Post: 10th January 2008, 18:51
  4. QPixMap and Memory leak
    By Krish_ng in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 14:18
  5. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42

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.