| 68 | |
| 69 | |
| 70 | === Memory === |
| 71 | |
| 72 | Any of the string class uses memory on the heap to allocate a StringImpl. The only way to avoid allocating new memory is to use the methods taking a constant literal. |
| 73 | |
| 74 | On 64bits, the memory used for StringImpl vary between 28 bytes to (28 + length + length * 2) bytes for a string from copy that has been converted to 16 bits. |
| 75 | |
| 76 | For example, a 10 characters string from copy converted to 16bits + the allocators alignment would typically take:[[BR]] |
| 77 | -28 + 10 = 38 -> typically allocated to 64bytes[[BR]] |
| 78 | -10 * 2 = 20 -> typically allocated to 32bytes[[BR]] |
| 79 | -->96bytes.[[BR]] |
| 80 | Be careful when allocating strings. |