**Describe the bug**
`SELECT i FROM generateRandom('i Array(Int8)', 1048575, 10, 1048577) LIMIT 1048575`

Memory limit should be respected.
{
    UInt64 bytes = 0;
    for (const auto & buffer : buffers)
    {
        std::lock_guard lock(buffer.mutex);
        bytes += buffer.data.allocatedBytes();
    }
    return bytes;
}
void StorageBuffer::alter(const AlterCommands & params, const Context & context, TableLockHolder &)
{
    auto table_id = getStorageID();
    checkAlterIsPossible(params, context.getSettingsRef());
    auto metadata_snapshot = getInMemoryMetadataPtr();
    
    
    
    optimize({} , metadata_snapshot, {} , false , false , context);
    StorageInMemoryMetadata new_metadata = *metadata_snapshot;
    params.apply(new_metadata, context);
    DatabaseCatalog::instance().getDatabase(table_id.database_name)->alterTable(context, table_id, new_metadata);
    setInMemoryMetadata(new_metadata);
}
void registerStorageBuffer(StorageFactory & factory)