Today, I try to use repeat() to generate 1GB text, and it occurs invalid memory alloc request size [1]. It is a limit from palloc(), then I try to reduce it, it still complains out of memory which comes from enlargeStringInfo() [2]. The documentation about repect() [3] doesn't mentaion the limitation.