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

Memory limit should be respected.
{
    String res;
    /** If you need to detach a part, and directory into which we want to rename it already exists,
        *  we will rename to the directory with the name to which the suffix is added in the form of "_tryN".
        * This is done only in the case of `to_detached`, because it is assumed that in this case the exact name does not matter.
        * No more than 10 attempts are made so that there are not too many junk directories left.
        */
    for (int try_no = 0; try_no < 10; try_no++)
    {
        res = (prefix.empty() ? "" : prefix + "_") + name + (try_no ? "_try" + DB::toString(try_no) : "");
        if (!volume->getDisk()->exists(getFullRelativePath() + res))
            return res;
        LOG_WARNING(storage.log, "Directory {} (to detach to) already exists. Will detach to directory with '_tryN' suffix.", res);
    }
    return res;
}
String IMergeTreeDataPart::getRelativePathForDetachedPart(const String & prefix) const
{
    
    assert(prefix.find_first_of('_') == String::npos);
    return "detached/" + getRelativePathForPrefix(prefix);
}
void IMergeTreeDataPart::renameToDetached(const String & prefix) const