Keep in mind that weapons fire also counts as a unit.
Btw, if you have a CD install, or an older version, the hard limit will be 1023. We upgraded that to 2047.
I believe the unit allocation function returns null (0) when it runs out of space, but the return value is never checked. If you check the crash address, it will probably say something about reading a low memory address close to 0. Quite likely from 0 - 120 (0x78 in hex).