Rewrite SystemString to handle memory allocation