Memory leak in string operations
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=2520
Reported by Serhat Sakarya, web@sakarya.nl
This code below generates ever increasing memory usage. I've tested this for Pike 7.2.30 and Pike 7.2.197 - both give the same problem of increasing memory usage of about 600kB after each gc().
int main()
{
string str;
int i;
while(1) {
for(i=0;i<10000;i++) {
str=(i%1)+"123456789012345";
}
gc();
sleep(1);
}
}
The effect seems to depend on:
- Using a variable addition to a string. I've used (i%1) so as to achieve the same length string every time.
- The length of the string. If one character is added to the constant string, then there is no problem. Only strings of length <= 16 seem to be affected.