A huge Swift file of literals .. cruelty to compilers

As a very lazy resort to getting a lot of data into my program, I created a Data.swift file of the form, containing ~20,000 lines:

let data: [(Double, Double)] = 
   (123.45, 234.56),
   . . . 
   (23.45, 134.56)
]

This is, of course, a travesty but it did cause the compiler serious problems. Specifically, my Mac ran out of application memory (not a big surprise) and panic'd. I'm not making any excuses for my actions but I did wonder if the compiler has sufficient protection from idiots like me.

7 Likes

Something like this should probably be made efficient eventually, do you want to file an issue with the general "shape" of your data (probably what you described)? No need to attach the full file.

2 Likes

In the sample that you posted, aren’t you missing the [ at the start of the data? Or did it just get omitted from the text?

I'll be happy to file an issue at GitHub if it's deemed worth it,

I will add here, while typing, that this problem has a life after death .. Xcode runs out of application memory, then macOS requests Xcode and other apps be force-quit, but it doesn't take long for that option to freeze up, followed by a forced restart.

That's all a 'normal' progression in the face of this pathology .. the kicker comes when, on the restart Xcode tries to restore its state and death by 'memory-hunger' repeats.

3 Likes

.. my typo in the example β€” I deleted 20,000+ lines and the β€œ[β€œ was lost with them.

1 Like