Sign in to follow this  
Followers 0
Cyber

FileRead - Error allocating memory

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

; "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

Share this post


Link to post
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
Sign in to follow this  
Followers 0