Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QRegularExpressionMatch memory consumption
QtWS25 Last Chance

QRegularExpressionMatch memory consumption

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 552 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mvidelgauz
    wrote on last edited by
    #1

    Hello,
    here is part of my code:
    @int Parser::SomeFunction(const QString &line, int start, int& fieldStart, int& fieldLength ) const
    {
    int end;
    ......
    if (0 == m_pRegExp)
    {
    ......
    }
    else
    {
    #ifdef KNOWN_PATTERN
    end = 19;
    #else

        QRegularExpressionMatch match = m_pRegExp->match(line,  start);
        if (!match.hasMatch())
        {
            return 0;
        }
    
        // currently we are requiring match to be found exactly at the position 'start'
        if (match.capturedStart() != start)
        {
            return 0;
        }
    
        end = match.capturedEnd();
    

    #endif
    }
    .....
    }
    @

    The program loads a text file and parses its lines one by one. The whole purpose of code in 'else' scope is to calculate where a field ends (integer 'end') in the next line passed to the function. When I compile with KNOWN_PATTERN #defined and load some test file, for which I know 'end' should become 19, my program consumes about 400 MB less memory than when compiled without KNOWN_PATTERN #defined. 400 MB is what all lines of my test file occupy in the memory (I can can calculate it based of file size and also I watched memory consumption when file was loaded and before parsing started).
    So it seems to me that QRegularExpressionMatch creates a copies of each line and does not release it.
    What am I missing here?
    Thanks!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved