Use only as many bytes as are needed in shared memory

Also don't specify size unless creating it.