Jump to content

Memory consumption on fileread


Recommended Posts

I have some memory-consumption issues on fileread operation (or maybe lack understanding of process)

i read some 116Mb RSS file in to memory. Before reading script uses 20/46 Mb, after - 266/631 Mb

Why memory consumption about 2 times of original filesize and peak memory consumption about 6 times of original filesize? Isn't it too mach? How i can reduce it?

 

_____MEMWrite(@ScriptLineNumber)

        $hXMLsource =   FileOpen($sXMLsourcePath,128)
        $sXMLsource =   FileRead($hXMLsource)
                        FileSetPos($hXMLsource,0,0)
        $RSS_FeedHead = FileRead($hXMLsource,4096)
                        FileClose($hXMLsource)

        $RSS_FeedBottom = "</rss>"

        _____MEMWrite(@ScriptLineNumber)

$RSS_FeedHead = StringLeft($RSS_FeedHead, StringInStr($RSS_FeedHead, "<Items>", 0, 1, 1) - 3)
$RSS_FeedBody = StringRegExp($sXMLsource, '(?s)(\h+\x3cItems\x3e.*?\x3c\x2fItems\x3e)', 3)

 

 

Func _____MEMWrite($iLN)
    $m = ProcessGetStats()
    ConsoleWrite("------------> Line "&$iLN&" memory = "&Round($m[0]/1000000,0)&"/"&Round($m[1]/1000000,0)&@crlf)
EndFunc

 

Link to comment
Share on other sites

Don't forget that AutoIt strings are UTF16 Unicode. This implies that reading, say 10 bytes of ASCII file produces a 10-character (20 bytes) string.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Reassigning a string to the empty string doesn't free the storage previously used: that only reset the string length. Rassigning to a different type (e.g. integer 0) will free the old storage.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...