B
B
Bombus2015-03-04 08:14:53
C++ / C#
Bombus, 2015-03-04 08:14:53

What are the methods for optimizing the size of the program (executable code)?

How to find out which part of the code contributes more to the final size of the program? Can such a question be asked?
It is required to optimize the size of the program for placement in the controller (ISP-DAS, processor 8086). The size of the "disk" is limited. Which optimization mechanisms to focus on (which contributes more)?
The first thing that suggests itself is to comment on a part of the code and look at the final size. But this can not always be done, because. There is a dependence of one piece of code on another. You can probably play with the compiler options. An option, but it is, if I may say so, integral, does not allow us to single out particulars with which we need to work.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Armenian Radio, 2015-03-04
@Bombus

You can start by studying the compiler options - there should be optimization modes for the size of the code, but performance will suffer.
Further, the linker can issue a resource allocation map, where you can see the size of each procedure.

D
Dmitry, 2015-03-04
@dnovikoff

I will add my colleagues. If we are talking about C / C ++ (judging by the tags so). Look at your compiler options. Let me give you an analogy: the gcc / clang compiler uses the -Os compilation key (s from the word size. That is, size optimization). For studio it will be /O1.
There are things that greatly "bloat" the code. For example, using templates can greatly increase the size of your binary, because each template instantiation is a new class.

S
Stoned Shaman, 2015-05-11
@StonedShaman

To all of the above, I will add that the final size of the application is also affected by the compiler itself. For example, programs compiled with clang may weigh less than those compiled with gcc.

S
Sergey Sapov, 2015-07-25
@softmart

Initially, you need to make sure that the code is not a solid monolith, but is a modular section that can be disabled if necessary ($ifdef).
By the way, this can also help in localizing hard-to-remove errors, you can turn off individual parts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question