Question

I really lack experience on developing things on Windows, and I may have missed some obvious things, try to stay calm :)

I have an application (Qt C++) which uses some .dlls from its own path (I mean I deliver those .dlls along with the .exe). When I deliver the app, I compress the dlls via upx. It dramatically compresses them and I can use those dlls without decompressing.

I have the impression that I am doing something wrong but it just works by chance, so I wanted to be sure, is it ok to use a compressed dll? Or should I expect unpredictable problems at anytime? (This is being the main question)

If .dlls can be used in compressed mode so why the earth do we have them uncompressed in the first place.

Was it helpful?

Solution

This is not something that "works by chance", UPX is intended to compress Win32-PE (and many other formats), whether that's executables or DLLs.

As for "Is it OK?", well yes, of course it is "OK", as long as you don't violate another party's license. This is highly unlikely to happen with anything related to Qt, but in principle, it is a possibility. One could for example be using some DLLs which have a license clause such as "distribution in binary form, blah blah, not allowed to modify". Say, something like a MSVC or DirectX redistributable, or some graphic card vendor's proprietary API. In any case, it's not a mistake to keep this in mind and check the licenses before risking to violate them.

Wording your question "Is it OK?" slightly different: "Is it wise?", the answer is: probably not. A few megabytes extra on the disk normally don't matter a lot. When you pack everything into an installer, and a user downloads it over the internet, the data is compressed anyway, so it's the same in that respect.

However, compression, whether you use UPX or another executable packer, or Windows' filesystem compression, has side effects. It causes additional address space fragmentation, it disables asynchronous transfers, and it forfeits the operating system's ability to discard pages from the DLL from the working set and to transparently reload them from the PE image upon access.

That last sentence means the operating system must make an allocation in the page file and it must write pages to the page file when your process' working set is moved out to make room for something else. There is no other way. Now what if the user has disabled page files...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top