About the release of qtablewidgetitem memory usage

Source: Internet
Author: User

In the current project, data in some tables is refreshed regularly, and the number of rows is not fixed. Each time I used to create a new qtabelwidgetitem, I applied for memory. However, because it cannot be released for the next time, you can only consider deleting the last allocated memory at the next refresh.

You can use the following method:

Obtain the rowcount of a table each time, traverse it, and use the UI. tablewidget-> item (I, j) returns a pointer-type item. As described in this document, if item is not set, 0 is returned, so we can judge it, if (item) and then delete item; then you can.

In this way, the memory applied for last time is released during each refresh to avoid increasing the memory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.