Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my application use more memory after I compress it with UPX, and what can I do about it?

Tags:

delphi

upx

I'm using the UPX compressor to compress my application written in Delphi XE. The file size goes from about 32 Mb to 8 Mb.

The strange thing I noticed, though, is that the occupation of the RAM increases significantly when running the compressed file. From 25/30 Mb goes to about 80 Mb. Is this normal or is it a problem you should keep? In my case, since the application runs on Windows Server 2008 remote desktop mode with multiple users, the system weighs disproportionately.

Why does this happen? How can I solve this problem?

like image 219
Enzo Costantini Avatar asked Feb 09 '12 21:02

Enzo Costantini


1 Answers

That's how EXE compressors work. They compress the disk file, not the executable code. To make the compressed file executable again, it needs to be uncompressed, and that uncompressed data is stored in memory. With an ordinary, non-compressed EXE file, the OS will load only the portions of the file that are required at the moment. The rest can stay on disk. Since your entire uncompressed application is in memory, that's why your memory usage appears higher.

Furthermore, the disk file can be shared by multiple users, whereas the memory containing the uncompressed executable is not shared. Each user running your program has a separate copy of the uncompressed program.

The 26 MB of disk space that you're saving by compressing your program are practically nothing on a shared remote-desktop server. Don't bother compressing the file. If you want to compress the file to save on bandwidth during distribution, then package your program in an installer that uncompresses the file once at installation time instead of an EXE compressor that needs to uncompress the file every time anyone runs it.

like image 96
Rob Kennedy Avatar answered Sep 27 '22 20:09

Rob Kennedy