Thanks for the test project. I've looked into it. There is no noticeable memory difference between the published and unpublished versions. But when you compile it, it does indeed use almost 40 MB more. The reason for this appears clear when looking in the code.

You have about 29000 variables defined in your script. The compiler stores all variable names in an XML list and in a hash file, which occupy about 20 MB for a script of this size. Additionally, the compiler assumes from your script size that the resulting code will be extremely large, and reserves another 16 MB for it. In fact your code is quite short, but the script size sums up to a huge memory requirement for compiling that code.

When you don't change the script often, use the automatic compiling option for saving that 40 MB. But this does not explain your problem with 600 MB extra memory, at least if you're not really using incredibly large scripts.