Format Function Leaks Memory

The following code will leak 1-2 mbytes of memory per second:

Dim s as string
Dim x as double
for ii as int64 = 1 to 30000000
x= ii
s = format(x,"#.################e")
next

if you replace 5th line with s = str(x) it does not leak. So it appears that the format function has a significant memory leak.

Workarounds:
Use str instead of format when possible??

Feedback report:

<https://xojo.com/issue/27431>

I did some testing… and it seems it is NOT FORMAT per se’ but the “e” parameter

that is memory remains stable with any format specifier in you sample as long as it does not have the “e” in it

So yes, I agree you seem to have found a “bug”,

Note it leaks if you change X to an integer or single as well… so it is the “e” that is causing the problem

Dave, I am glad to see that you were able to reproduce it. I added some info to the feedback report. I am on MacOSX 10.8.4 compiling with Cocoa framework using Xojo 2013R1. I am measuring real memory usage with activity monitor.

The more memory leaks we find in Xojo and get fixed the better.

That is EXACTLY what I am using… and how I measured this as well…

Same behavior under Windows 7 x64.