Jump to content

Recommended Posts

Posted

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

 

Posted (edited)

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
  Reveal hidden contents

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)

Posted

Free memory by setting variables that you don't need to 0 or blank ("") after you have your results.

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

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.

  Reveal hidden contents

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)

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
  • Recently Browsing   0 members

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