clever-lang/clever — Issue #132: Refcounted CString
Author: felipensp
Created: 2012-02-23 15:53:35+00:00
State: open
Labels: Critical, Performance, VM

We have to implement a non-permanent CString using reference counting to be used in the return statements. Currently we just stores all the string in the table, and in the end we free all them.

A simple script to notice such problem:
```
String a = "f"; Int i = 0; while (i < 100) { String a(a * i++); println(a); }
```

A graphic generated by Valgrind's massif tool:

```
KB
92.69^ :
| @:::@#::
| :::::@@:::@#::
| @:::::::::::::: :@@:::@#::
| :@:: ::::::::::: :@@:::@#::
| @@:@:: ::::::::::: :@@:::@#::
| @:@@:@:: ::::::::::: :@@:::@#::
| ::@:@@:@:: ::::::::::: :@@:::@#::
| :::@:@@:@:: ::::::::::: :@@:::@#::::
| :@::::@:@@:@:: ::::::::::: :@@:::@#::::
| :@::::@:@@:@:: ::::::::::: :@@:::@#:::::
| @@::@::::@:@@:@:: ::::::::::: :@@:::@#::::::
| @@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::
| :@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@
| @:@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@
| @@@:@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@:
| @ @:@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@:
| :@@ @:@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@::
| :::@@ @:@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@:::
| :::@@ @:@@ ::@::::@:@@:@:: ::::::::::: :@@:::@#::::::@:::
0 +----------------------------------------------------------------------->Mi
0 9.211
```