QRegularExpressionMatch memory consumption



  • 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!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.