WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Error Codes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Error Code 3096: Out of memory for strings

Keywords:  Error Code 3437 Addextender DLL load failed	NWCALLS.DLL

3096: Memory Allocation Failure: Out of memory for strings.

Question:

I am getting the following 3096 error:
WinBatch\Error Codes\3096 Out of memory for strings.txt
3096 Memory Allocation Failure
Out of Memory for Strings
A1=RegQueryItem(@REGMACHINE, THEKEY)
Winbatch 32 96B
Any advice on getting thru it?

Answer:

You've burned up a whole bunch of your stringspace.

The line listed most likely is the straw that broke the memory managers back. (Unless the THEKEY item points to something awfully big).

Basically you have something in the program using large string variables to the point where it exceeds the design goals of the language.

Basic limitations here are:

  1. Max single variable size is 7-8K.

  2. Winbatch 98F has unlimited string space (only limited by your memory).

    In 32-bit version of WB 99A, we changed the memory allocation for strings to be dynamic. This means that you should no longer receive an error 3096 ("Out of memory for strings"), unless Windows itself is completely out of memory (unlikely).

    Max total string space is roundabouts 32K (65K for Winbatch 97, up to Winbatch version 98F, and virtually unlimited thereafter).

Basically what you are up against is that WinBatch has a 32K (65K for WB97) buffer for its string variables.

During processing, several copies of a string variable might exist. The largest reasonable size for a single string variable is maybe about 7-8K. And then you cannot have more than one or two of them.

To handle large amounts of data it is possible to use binary buffers. However it can get a tad tricky.

Here is an (untested) example. Let's say you have a text file of about 100K, and you want to uppercase the whole thing. Obviously it cannot be done directly with WinBatch variables. You could read a line at a time and uppercase it and write it out, but that would take forever. So without further ado...

WinBatch\Error Codes\3096 Out of memory for strings.txt
fname="C:\temp\mybigfile.txt"
fsize=FileSize(fname)
bb=BinaryAlloc(fsize)
BinaryRead(bb,fname)

blocksize=1000
blocks=fsize/blocksize ; Integer divide
remainder = fsize mod blocksize

for xx=1 to blocks
offset=(xx-1)*blocksize
line=BinaryPeekStr(bb,offset,blocksize)
line=strupper(line)
BinaryPokeStr(bb,offset,line)
next

; scoop up last bit
offset=blocks*blocksize
line=BinaryPeekStr(bb,offset,remainder)
line=strupper(line)
BinaryPokeStr(bb,offset,line)

BinaryWrite(bb,fname)
BinaryFree(bb)
Message("All","Doned")


Also see the article:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Memory~and~System~Resources+Memory~Allocation~StringSpace~and~Arrays.txt


Article ID:   W12953
Filename:   3096 Out of memory for strings.txt
File Created: 2017:08:29:12:01:06
Last Updated: 2017:08:29:12:01:06