Out of memory error


Description of the issue:
Having an issue where brave will start allowing ram to run away during extraction phase of downloading a new module via our WAMP stack and then at roughly 70% point it will hit the 4G limit and crash with OOM error.
In FF, & chrome we don’t see this issue. we’re using the default configuration of the browser.
I’m not sure what data you need in order to be helpful.

How can this issue be reproduced?

  1. attempt to extract via ajax a large file while maintaining a progress bar

Expected result:
ram usage stays near other browsers and file extraction completes
Brave Version( check About Brave):
1.68.141

Additional Information:
code we use during the extraction phase is this…

if ( $process ) {
            $filesExtracted = 0;
            $buffer         = '';

            while ( !feof( $process ) ) {
                $buffer .= fread( $process, 262144 ); // Read in smaller chunks of 64KB

                while ( ($newlinePos = strpos( $buffer, "\n" )) !== false ) {
                    $line   = substr( $buffer, 0, $newlinePos + 1 );
                    $buffer = substr( $buffer, $newlinePos + 1 );

                    if ( $progressCallback && preg_match( '/^- (.+)$/', $line, $matches ) ) {
                        $fileName = trim( $matches[1] );

                        // Check if the extracted item is a file and not a directory
                        if ( substr( $fileName, -1 ) !== '\\' ) {
                            $filesExtracted++;
                            if ( $filesExtracted <= $numFiles ) {
                                call_user_func( $progressCallback, $filesExtracted, $numFiles );
                            }
                        }
                    }
                }

                // Clear the buffer periodically to release memory ( 128k chunks )
                if ( strlen( $buffer ) > 524288 ) {
                    $buffer = '';
                }
            }

            $returnVar = pclose( $process );
            Util::logDebug( 'Command return value: ' . $returnVar );

            if ( $returnVar === 0 ) {
                Util::logDebug( 'Successfully unzipped file to: ' . $destination );

                return ['success' => true, 'numFiles' => $numFiles];
            }
            else {
                Util::logError( 'Failed to unzip file. Command return value: ' . $returnVar );

                return ['error' => 'Failed to unzip file', 'numFiles' => $numFiles];
            }
        }