CA-135774: don't preallocate memory, use malloc and cache it instead