Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Large Object Files

Posted on 2006-06-27
Medium Priority
Last Modified: 2012-08-14
I have a library that I build using MSVC++ 6.0.  It contains a lot of classes, but most of them are very small.  When I build even the small classes, I get object files that are over 800KB in size!  My library ends up being 131MB (and that is for the Release library).  Most of these small classes subclass another class that is 165KB in size which subclasses yet another class 5kb in size.   I tried to build for mimum size and it really doesn't help much.  Does it seem reasonable that my .obj files would be so large.

Thanks in advance for any help.
Question by:jribble
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 86

Expert Comment

ID: 16995949
Do you have some more information? Is this a static library? What kind of code is in there, what does it do? What are your compiler/linker settings?

Author Comment

ID: 16996084
Here is the information requested (let me know if you need more specific information). Thanks!

Yes, this is a static library.  It includes functions from another static library.  

From Project Options:

/nologo /MD /W3 /GX /O1 /I "\source\gpmqNT\Common\MesCommonLib\Versions\v2.8.0\Include" /I ".\Include" /I "X:\source\gpmqNT\UniversalCfg" /I "X:\source\gpmqNT\Logger\Include" /I "X:\source\utility\encdec\encdec2" /I "\source\gpmqNT\Common\MesReportLib\Versions\v2.4.1\Include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"Release/GPMQDLL.pch" /YX"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c

Most of the classes are used to map a database table.  These objects can be created and based on the columns, SQL is generated to insert or update rows in our DB2 database.  Here is a sample (note they do not contain a lot of code, but do subclass another larger class CDomain).

// BinFeetOfAir.cpp: implementation of the CBinFeetOfAir class.

#include "stdafx.h"
#include "BinFeetOfAir.h"
#include "Columns.h"
#include "Brokers.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW

Sample .hpp file
// BinFeetOfAir.h: interface for the CBinFeetOfAir class.

#if !defined(AFX_BINFEETOFAIR_H__E55DA8F6_C198_424B_8ED7_E17E945A86F4__INCLUDED_)
#define AFX_BINFEETOFAIR_H__E55DA8F6_C198_424B_8ED7_E17E945A86F4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Domain.h"
#include "Domains.h"

class __declspec(dllexport)CBinFeetOfAir : public CDomain  
      virtual ~CBinFeetOfAir();


#endif // !defined(AFX_BINFEETOFAIR_H__E55DA8F6_C198_424B_8ED7_E17E945A86F4__INCLUDED_)

Sample .cpp file
// Construction/Destruction

      addColumn(new CColumn(INTEGER_COLUMN,this,INGREDIENT_BIN_NUMBER));
      addColumn(new CColumn(INTEGER_COLUMN,this,FEET_OF_AIR));
      addColumn(new CColumn(DOUBLE_COLUMN,this,BUSHELS));


LVL 86

Expert Comment

ID: 16996170
The linker settings would be helpful also ;o)
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16996210
From the Library tab, here are the Project Options:
/nologo /out:"Release\GPMQDLL.lib"

Is that what you were looking for - since this is a static library, there isn't much.
LVL 86

Expert Comment

ID: 16996503
Hmm, odd. Do al the onject files become that large? What does 'dumpbin' report about the entries in the .lib?

Accepted Solution

e_tadeu earned 2000 total points
ID: 17000660
I think it must be one of these two:

1) You are using too much templated code, and too much template instantiations
2) You are including a header from your .cpp files with too much static data on it

Also, try to disable header pre-compiling.

Author Comment

ID: 17004288
As it turns out, we had a lot (approximatly 600) of the following type of definition in a header file...

const CString BLA_BLA = "BLA_BLA";

What happened with these declarations was that any .cpp file that included the headers defined ALL of these instances of
CString object.

We changed all global CString constant objects to macro definitions that create exactly the same objects dynamically.

Here are the details, based on a small sample code.

 base.h contained:
 const CString SOME_ID = "SOME_ID";
 class CBase {
   // constructor and destructor.
   // ...

 base.h contains:

 #define SOME_ID CString(CBase::_SOME_ID)
 class CBase {
 static const char* _SOME_ID;
   // constructor and destructor.
   // ...

 added to base.cpp:
 const char* CBase::_SOME_ID = "SOME_ID";

Maybe there was a way to do this simpler, e.g. by only one macro declaration:
 #define SOME_ID CString("SOME_ID")


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

604 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