Out of memory exception

Hallo,

in a WE project I get an “Out of memory exception” when using “Request.print”

What I try to do is to read a 500MB file into a memoryblock and send it to a client’s browser.
(It works with files of 200MB size)

The machine I use is running XP with 3GB memory assigned (it’s a virtual maschine)

Here is the code in HandleSpecialURL:

[code]dim bs as binarystream
dim mb as memoryblock
dim f as Folderitem

f = GetFolderItem (“c:\test\test.avi”)

bs = bs.open (f,False)
mb = bs.Read (bs.Length) 'read file into memoryblock.
bs.Close

'send file to client
Request.print mb 'Out of memory exception[/code]

I wonder why I get this execption even though I have 3GB memory in the machine and according to Taskmanager there is 1.5GB RAM available.
Maybe memory fragmentation is a problem so I don’t get 500MB memory in one chuck? OK…but why then does this exception occur in “Request.print mb” and not earlier when I read the file into the memoryblock?
In the Debugger I can see that the file obviously was read successfully into memory, the debugger says size of mb is 521119744 (which is exactly the size of the file) - and the amout of available memory in taskmanager is reduced by about 500MB.
So I think that the file was read into memory (and it can not be memory fragmentation) ?

Well, reading here gives a 500 MB string in memory. Than you convert to a 500 MB memoryblock.
And you print the memoryblock converting it back to string using another 500 MB in memory.
And finally the request created in framework with headers which gives again 500 MB.
And that must go to the socket send buffer (another 500 MB allocation).

On the end you use a lot of memory and your app on Windows is limited to around 1.8 GB in total.

PS: Try to avoid the conversions from memoryblock <-> string.