Discussion:
Interesting Textstream limit
(too old to reply)
Mayayana
2014-07-07 03:19:53 UTC
Permalink
A tidbit of info for future reference:
I've just been dealing with parsing a CSV file that's 173 MB.
I needed to adjust each line and write a new file. The new file
is 82 MB. Everything worked fine. I split the CSV into a
string array, wrote each new line to a new array, then used
Join to make a string. But when I tried to write it to disk I
kept getting an out of memory error. Textstream just
couldn't do it. I ended up opening the file for appending, then
wrote 1 MB at a time from the string until it was all written
to disk. That worked fine, even though Textstream.Write the82MBstring
failed. If anyone knows what the actual limit is I'd be curious
to know.
Auric__
2014-07-07 07:02:16 UTC
Permalink
Post by Mayayana
I've just been dealing with parsing a CSV file that's 173 MB.
I needed to adjust each line and write a new file. The new file
is 82 MB. Everything worked fine. I split the CSV into a
string array, wrote each new line to a new array, then used
Join to make a string. But when I tried to write it to disk I
kept getting an out of memory error. Textstream just
couldn't do it. I ended up opening the file for appending, then
wrote 1 MB at a time from the string until it was all written
to disk. That worked fine, even though Textstream.Write the82MBstring
failed. If anyone knows what the actual limit is I'd be curious
to know.
I would guess 64MB. Try your script with the output size doubled on each run
and see where it fails.
--
You got a plan already?
Mayayana
2014-07-07 13:23:52 UTC
Permalink
|> If anyone knows what the actual limit is I'd be curious
| > to know.
|
| I would guess 64MB. Try your script with the output size doubled on each
run
| and see where it fails.
|

Yes, obviously I could spend the time to work that out,
but the point of asking is so that I don't have to. :)

I don't know any reason that 64 million should be a
particular limit. A 16-bit number goes up to 65000+.
A 32-bit number goes up to about 4 billion (or 2 billion
if it's a signed data type). It could have something to do
with WScript limits, I suppose. I looked online but so
far haven't found anything.
Dave "Crash" Dummy
2014-07-07 15:32:16 UTC
Permalink
|> If anyone knows what the actual limit is I'd be curious | > to
know. | | I would guess 64MB. Try your script with the output size
doubled on each run | and see where it fails. |
Yes, obviously I could spend the time to work that out, but the point
of asking is so that I don't have to. :)
I don't know any reason that 64 million should be a particular limit.
A 16-bit number goes up to 65000+. A 32-bit number goes up to about 4
billion (or 2 billion if it's a signed data type). It could have
something to do with WScript limits, I suppose. I looked online but
so far haven't found anything.
Since I don't have a life, I did some fooling around. I had no problem
creating 268,435,456 byte string and writing it to file with a single
operation.
'--------------test.vbs-----------
str="X"
for n=1 to 28
str=str&str
next
msgbox len(str)
set fso=CreateObject("Scripting.FileSystemObject")
set oFile=fso.CreateTextFile("string.txt")
oFile.write str
'-----------------------------------
--
Crash

Today is the first day of the rest of your life,
and there's not a damned thing you can do about it.
Dave "Crash" Dummy
2014-07-07 15:38:17 UTC
Permalink
Footnote:
I have 4 GB of RAM. I notice that you are using Outlook Express and
therefore presumably running XP. You are maybe limited by the OS and
available RAM, not VBScript.
--
Crash

English is not my native tongue; I'm an American.
Mayayana
2014-07-07 19:06:16 UTC
Permalink
Yours gives me the same out of memory error. I have
4 GB RAM, which is really something like 3.2 GB, but still
far more than enough for the job. I am on XP32. Maybe
the limit is with 32-bit WScript. But I still can't think of
any reason for a limit under 2 GB.

|
| Since I don't have a life, I did some fooling around. I had no problem
| creating 268,435,456 byte string and writing it to file with a single
| operation.
| '--------------test.vbs-----------
| str="X"
| for n=1 to 28
| str=str&str
| next
| msgbox len(str)
| set fso=CreateObject("Scripting.FileSystemObject")
| set oFile=fso.CreateTextFile("string.txt")
| oFile.write str
| '-----------------------------------
| --
| Crash
|
| Today is the first day of the rest of your life,
| and there's not a damned thing you can do about it.
Dave "Crash" Dummy
2014-07-07 21:17:59 UTC
Permalink
Post by Mayayana
Yours gives me the same out of memory error. I have
4 GB RAM, which is really something like 3.2 GB, but still
far more than enough for the job. I am on XP32. Maybe
the limit is with 32-bit WScript. But I still can't think of
any reason for a limit under 2 GB.
That could be. I am running W7 x64.
--
Crash

No government is valid that denies people the right to leave.
GS
2014-07-07 17:45:09 UTC
Permalink
Post by Mayayana
I've just been dealing with parsing a CSV file that's 173 MB.
I needed to adjust each line and write a new file. The new file
is 82 MB. Everything worked fine. I split the CSV into a
string array, wrote each new line to a new array, then used
Join to make a string. But when I tried to write it to disk I
kept getting an out of memory error. Textstream just
couldn't do it. I ended up opening the file for appending, then
wrote 1 MB at a time from the string until it was all written
to disk. That worked fine, even though Textstream.Write the82MBstring
failed. If anyone knows what the actual limit is I'd be curious
to know.
I assume you mean you wrote back in 'blocks' or 'chunks' of text! I've
been trying to 'collect' code samples for doing exactly that in as
efficient a manner as possible. Would you be interested in contributing
your code? Thanks in advance...
--
-
Garry

Free Usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2014-07-07 19:07:43 UTC
Permalink
| I assume you mean you wrote back in 'blocks' or 'chunks' of text! I've
| been trying to 'collect' code samples for doing exactly that in as
| efficient a manner as possible. Would you be interested in contributing
| your code? Thanks in advance...
|

You're welcome to it, but it's nothing special:

Sub WriteFile(Path, content)
Set TS = FSO.OpenTextFile(Path, 8, True)
Dim i6
i6 = 0
Do
If Len(content) > (i6 + 1000000) Then
TS.Write Mid(content, i6 + 1, 1000000) 'content
i6 = i6 + 1000000
Else
TS.Write right(content, (len(content) - i6))
Exit Do
End If
Loop
TS.Close
Set TS = Nothing
End Sub
GS
2014-07-07 21:02:51 UTC
Permalink
Post by Mayayana
| I assume you mean you wrote back in 'blocks' or 'chunks' of text! I've
| been trying to 'collect' code samples for doing exactly that in as
| efficient a manner as possible. Would you be interested in contributing
| your code? Thanks in advance...
|
Sub WriteFile(Path, content)
Set TS = FSO.OpenTextFile(Path, 8, True)
Dim i6
i6 = 0
Do
If Len(content) > (i6 + 1000000) Then
TS.Write Mid(content, i6 + 1, 1000000) 'content
i6 = i6 + 1000000
Else
TS.Write right(content, (len(content) - i6))
Exit Do
End If
Loop
TS.Close
Set TS = Nothing
End Sub
Thanks.., much appreciated!
--
-
Garry

Free Usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Loading...