可以安全传递给reserveCapacity(_:)
的最大输入是什么?
var a = [0]
a.reserveCapacity(Int.max)
// Results in EXC_BAD_INSTRUCTION (code=EXC_386_INVOP, subcode=0x0)
a.reserveCapacity(Int.max / 16)
// Results in EXC_BREAKPOINT (code=EXC_386_BPT, subcode=0x0)
// Console log:
// malloc: *** mach_vm_map(size=4611686018427392000) failed (error code=3)
// *** error: can't allocate region
// *** set a breakpoint in malloc_error_break to debug
我找不到任何方法来处理这两种错误。