Solved

Exe size question

Posted on 2003-11-27
8
226 Views
Last Modified: 2010-04-05
Hi,

If I compile the code bellow and I'll get a 376KB in Delphi 5.
The strange is if I remove the line: data:= TDataSource.Create(nil);
I'll have 288KB. Just because of one instruction?
Is this normal? If yes, can you explain me why?
Thanks,
Luis

program Project1;
uses Db;
var data:TDataSource;

begin
  data:= TDataSource.Create(nil);
  writeln('Hello World');
end.
0
Comment
Question by:lfgmartins
8 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 9833097
The instant you use a function or method from Db the compiler really links in code from DB.
Declaring only a variable has no effect. An object variable is only a pointer.
You are lucky here. Some units drag in a megabyte.
The VCL is very much interlinked so using almost any method from any object drags in most of the VCL code.
0
 
LVL 22

Expert Comment

by:mnasman
ID: 9833128
I think Delphi will not include the DB unit when you remove the line, because it doesn't require for any operation, but when you add it, it will include the DB unit, which it's big unit so it's increase the size of the exe file
0
 

Author Comment

by:lfgmartins
ID: 9834347
OK Robert.
I agree and understand your explanation.
But how is the process. See this example:
The original size is 30 KB.
The Db include takes 250KB. = 280KB
The variable declare takes nothing more.
So why the instruction: data:= TDataSource.Create(nil);
Adds more 100KB. = 380KB
When we use the Db unit it doesn't include everything? If it included, then the size shouldn't increase when we run that instruction? Or should?
There's got to be a way to round this size increase problem? Whatelse we should all have to create our Db unit and so on...

Regards,
Luis
0
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 500 total points
ID: 9835129
I forgot.
The parameter nil. That drags in TComponent.
Code size also comes from intialization sections and resources.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 17

Expert Comment

by:geobul
ID: 9836068
Hi,

In Delphi 5 db unit uses Windows, SysUtils, Classes and Graphics units also. Perhaps that is the reason.

Regards, Geo
0
 
LVL 2

Expert Comment

by:j42
ID: 9836350
Hi Luis,

> The original size is 30 KB.
> The Db include takes 250KB. = 280KB
I'm just curious. Where do these numbers come from?
TIA
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9836557
Hi,

If I remember good, the schema is:

Using TComponent as base class, throws in 300Kb( visual VCL ).
Using TObject as base class throws in 100Kb( class management ).

Using any class throws in:

- Class's size
- Inherited class's size
- All class sizes of compound classes. When they're shared they count for 1 in size. Example: if you use 300 TEdit,
  then it fits in the 300Kb for the Visual VCL. If you use a custom class, it throws in its size.

HTH,

Andrew
0
 

Author Comment

by:lfgmartins
ID: 9837269
Hi,

J42, this is the size of my code in Delphi 5. It's just for you to have an idea.
DeerBear, the TObject don't occupy much because it's declared in the System unit that's automaticlly included in all projects, right?
Thanks to all.
Luis
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now