As I mentioned in a previous blog, CEF is a great project and framework. However, one thing I noticed was the size of the main dll (libcef.dll). For the version of CEF I was using the libcef dll was ~33MB. Quite big. In fact this was the largest file that was being loaded into the installer. So I took to the developer's Surely there was someway to reduce the size of this file. It seems I wasn't the first person to notice the size of this file. I came across this thread on the CEF forum. Someone mentioned that they used a tool called UPX to pack the dll and that this greatly reduced the file size. Marshall Greenblatt (the CEF project owner) said that this may reduce the file size but it could negatively affect load time. I was still curious. I decided I wanted to try UPX. Worst case scenario was that it affected load time and therefore I would have to look for another solution. Worth a try then.

UPX stands for Ultimate Packer for eXecutables. How could I go wrong with a name like that? UPX is distributed with full source code under the GNU General Public License v2+, with special exceptions granting the free usage for commercial programs as stated in the UPX License Agreement. Perfect for my requirement. Its fast (~10 MB/sec decompression), universal (works on a large number of executable formats) and portable (written in C++). One drawback for me is that UPX currently does not support compression of Windows 64-bit dlls. Though it is an open source project so I can't complain. If 64-bit dll compression ever became important then I guess I could contribute to the project rather than moan about it not being implemented yet. Not so much of a problem for my current project as the libcef.dll is 32-bit.

So I downloaded the windows version of UPX from the UPX project website. The tool itself is a command line tool. Super simple to compress a dll. One line of code needed:

upx --brute libcef.dll

Done. I compared the file size of the libcef.dll before and after compression. Before the dll was ~33MB and after ~9MB. Amazing difference. I didn't want to get too excited as I hadn't tested the compressed dll yet. I was aware that there may be loading issues. So I added the dll to my project and launched the application. It worked first time. I have yet to notice any difference at all. Load time seems to be unaffected. Fantastic result.

In conclusion, if you want a dll packer to reduce the size of your dll or exe, definitely consider UPX.