WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mhall on January 10, 2016, 10:05:43 PM

Title: VM Alloc 487 error
Post by: mhall on January 10, 2016, 10:05:43 PM
Hi Tony,

So, I'm running into the above error when dealing with a large-ish (11MB) string.

The scenario is this ...

order_getjson()
This is a function that accepts a list of order IDs and returns a string of order JSON objects. Right now, to build this string, I first dimension an array with elements to hold each individual order's JSON. Then I loop through the order ids and either read a pre-built json file cached on disk or, if that doesn't exist, call a build function to create/cache the JSON string for that order with its items, etc. and return the result - which I then insert into an array slot.

At the end of order_getjson, I use arrayItemize() with a ',' delimiter to return one large string to the original calling function. I also explicitly drop() the array and temp string variable.

However, after returning from order_getjson - as soon as I attempt to insert this string into another string to be output by Webbatch I get the VM Alloc error.

This seems to be specifically related to the use of an ArrayItemize because ...

INTERESTING THING #1:
This whole operation works if - instead of using an array to hold the JSON strings in order_getjson, I instead use FileWrite to build up a temp file. Then I return the string using FileGet(). No errors. (This is the method I was previously using - I thought an array might be faster than writing to disk).

INTERESTING THING #2:
While I was writing this, I've also found that this operation works if I use the array but, instead of returning the results of arrayItemize(), I first write them to a temp file and then re-read them with FileGet() and return that data instead.

So I'm not broken - I can make things work. But, I found the phenomena odd and thought I would mention it in case you can give me any insight or it sounds like something isn't working right.

Oh, this is on WebBatch 2015A.

Regards,
Micheal
Title: Re: VM Alloc 487 error
Post by: td on January 11, 2016, 07:20:40 AM
You are attempting to commit more string memory than is reserved.  In short, you are running out of string space when you use ArrayItemize.    The function uses a lot of string memory to do its job.