Jump to content



Photo

FileRead - Error allocating memory


  • Please log in to reply
7 replies to this topic

#1 Cyber

Cyber

    Polymath

  • Active Members
  • PipPipPipPip
  • 215 posts

Posted 28 November 2008 - 11:00 AM

Hi!
I must do read a file
the code is simple:


$filename = "D:\ter\TE.txt"

$timer = TimerInit()

$SuperMegaGigaFile = FileRead($filename)

MsgBox(0,"",Round(TimerDiff($timer)/1000))



The problem?
The file size of the file is: 460m
text file

:)
Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key





#2 dbzfanatic

dbzfanatic

    functional psychopath!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,084 posts

Posted 28 November 2008 - 11:13 AM

To read a file that large you'd need roughly 2GB of RAM to run effectively. How much do you have? There are also threads on reading files by parts through buffers. Try one of those.

#3 Cyber

Cyber

    Polymath

  • Active Members
  • PipPipPipPip
  • 215 posts

Posted 28 November 2008 - 01:41 PM

I have 2 gb
i try with buffer, the name of the function?
thanks
Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

#4 dbzfanatic

dbzfanatic

    functional psychopath!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,084 posts

Posted 28 November 2008 - 01:46 PM

It's not just one function, it's a custom method. Just search the forum for "file buffer" or something similar. Also you need to realize the 2GB was a guess as to how much you would need, you may need more you may not need that much.

#5 Cyber

Cyber

    Polymath

  • Active Members
  • PipPipPipPip
  • 215 posts

Posted 28 November 2008 - 02:49 PM

I try
thanks
Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key

#6 Pain

Pain

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 627 posts

Posted 28 November 2008 - 04:12 PM

Here you got the UDF that dbzfanatic were talking about

http://www.autoitscript.com/forum/index.ph...mp;#entry336438

#7 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 28 November 2008 - 05:35 PM

All needed API functions for that are now included in standard AutoIt's UDF WinAPI

Here is example of use:

http://www.autoitscript.com/forum/index.php?showtopic=76829

#8 AZJIO

AZJIO

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 996 posts

Posted 28 April 2012 - 08:25 PM

Plain Text         
; "Error allocating memory." ; MAX_BINARYSIZE 2,147,483,647 Maximum bytes of binary data. ; MAX_STRINGLEN 2,147,483,647 Maximum string length. $Path = "D:TmpFile.tmp" $Size = 200*1024*1024 ; 200 Mb If FileExists($Path) Then FileDelete($Path) RunWait(@Comspec&' /C fsutil file createnew "' & $Path & '" ' & $size, '', @SW_HIDE) If FileExists($Path) Then _Open($Path) Func _Open($Path) $file = FileOpen($Path, 0) $text = FileRead($file) FileClose($file) MsgBox(0, Round(FileGetSize($Path)/1024/1024, 2)&' Mb', 'Yes') EndFunc





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users