473,779 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

/CLR in VC8 bloats image with unreferenced code


We upgraded a bunch of MEC++ code to C++/CLI about 10 months ago and we've
noticed that our images bloated quite a lot in the process. Upon
investigating I observed that when a /clr compiland includes a header file
for a native type that has an inlined copy constructor, that both the
inlined copy constructor and the inlined destructor for that same type will
end up in my mixed image, even though there is no reference made to that
native type from the source code of my dll at all. This is true even if the
..h containing the native type is included in a #pragma unmanaged section of
my compiland.

This seems like a bad compiler bug to me. I should pay zero runtime penalty
for including type information for types that I do not reference at all.
Don't you agree? Otherwise I have to go to the almost impossible difficulty
of minimizing the native type information observed by my mixed compiland.
But that ain't the C++ I know. That is an intractable task.

This bug is particularly annoying when it forces you to link with an import
library for a dll that you shouldn't have to link with at all. Suddenly your
binding closure balloons for no justifiable reason. This happens when you
see a native type (that you do not use) with an inline copy constructor and
destructor that references something in some other .dll (that you also do
not use). This bug may have something to do with exception handling/stack
unwinding. The linker errors that can be observed when unexpected stuff is
dragged into your .dll image often mention some "_unwindfunclet " symbol that
I know nothing about. This dragging in of unused code into images is
increasingly responsible for breaking our builds.

I implore someone from the Visual C team to investigate this. Reproducing it
is trivial. Start with a native hello world C++ program that arbitrarily
includes some not-really-referenced-or needed headers for some native types
that have inlined copy constructors and destructors that call out to other
..dlls whose import libraries you do not link with. Put #pragma managed at
the very top of the program and first make sure that it compiles just fine
as a pure native image and that it runs. Now, slap /CLR on the compile and
try again. Now you will get link errors and you will see that it tracks
back to the unused native types that have inlined copy constructors.

Bern McCarty
Bentley Systems, Inc.

Oct 9 '07 #1
1 1452
Before anyone asks...

Where I said "Put #pragma managed at the very top of the program and first
make sure that it compiles just fine
as a pure native image and that it runs."

.....I meant to say "Put #pragma unmanaged...... "

-Bern
"Bern McCarty" <Be**@newsgroup s.nospamwrote in message
news:BE******** *************** ***********@mic rosoft.com...
>
We upgraded a bunch of MEC++ code to C++/CLI about 10 months ago and we've
noticed that our images bloated quite a lot in the process. Upon
investigating I observed that when a /clr compiland includes a header file
for a native type that has an inlined copy constructor, that both the
inlined copy constructor and the inlined destructor for that same type
will end up in my mixed image, even though there is no reference made to
that native type from the source code of my dll at all. This is true even
if the .h containing the native type is included in a #pragma unmanaged
section of my compiland.

This seems like a bad compiler bug to me. I should pay zero runtime
penalty for including type information for types that I do not reference
at all. Don't you agree? Otherwise I have to go to the almost impossible
difficulty of minimizing the native type information observed by my mixed
compiland. But that ain't the C++ I know. That is an intractable task.

This bug is particularly annoying when it forces you to link with an
import library for a dll that you shouldn't have to link with at all.
Suddenly your binding closure balloons for no justifiable reason. This
happens when you see a native type (that you do not use) with an inline
copy constructor and destructor that references something in some other
.dll (that you also do not use). This bug may have something to do with
exception handling/stack unwinding. The linker errors that can be
observed when unexpected stuff is dragged into your .dll image often
mention some "_unwindfunclet " symbol that I know nothing about. This
dragging in of unused code into images is increasingly responsible for
breaking our builds.

I implore someone from the Visual C team to investigate this. Reproducing
it is trivial. Start with a native hello world C++ program that
arbitrarily includes some not-really-referenced-or needed headers for some
native types that have inlined copy constructors and destructors that call
out to other .dlls whose import libraries you do not link with. Put
#pragma managed at the very top of the program and first make sure that it
compiles just fine as a pure native image and that it runs. Now, slap
/CLR on the compile and try again. Now you will get link errors and you
will see that it tracks back to the unused native types that have inlined
copy constructors.

Bern McCarty
Bentley Systems, Inc.
Oct 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2082
by: Halfdan Holger Knudsen | last post by:
goodday all - here's a snippet of code that just doesn't seem to work...at all! But I haven't got the faintest idea why I keep getting an unref. local var. error. Take a look - I know I can get good help here. And PS: Thanks beforehand. If you're wondering - it's an attempt at a (crude) reproduction of the string.split() functionality for learning purposes. ---------------------- #! /usr/bin/env python
1
2488
by: Tzu-Chien Chiu | last post by:
I know many linkers can remove unreferenced functions while linking the object files, but I need a tool/script to list all unreferenced symbols. -- Tzu-Chien Chiu XGI Technology, Inc - Extreme Graphics Innovaion
0
1281
by: NetWalker | last post by:
I am trying to serialize object using BinaryFormatter like below: //======================== void SomeFunction() { SomeClass anObject; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, anObject);
11
11819
by: Alzane | last post by:
I'm new to C++ programming. I have an exercise that I have written code for but getting warnings. Can I get some help? #include "stdafx.h" #include <string.h> #include <stdio.h> #include <stdlib.h>
22
8323
by: John Fisher | last post by:
void f(int p) { } Many (most?) compilers will report that p is unreferenced here. This may not be a problem as f may have to match some common prototype. Typically pointers to functions are involved. For a long time I have used
2
2859
by: Alexey.Murin | last post by:
The application we are developing uses MS Access 2003 database (with help of ADO). We have noticed that during massive records updating the size of the mdb file increases dramatically (from 3-4 to 200-300 Mb). After compacting the file shrinks back to 3-4 Mb. I have performed the following experiment. I created a test database containing only one table with two columns (Key number, Value text(50)). The table contains 10 thousands...
9
3713
by: dotnetismylife | last post by:
Hi all, I have a question, in the following code: using System; using System.Diagnostics; namespace ConsoleApplication1 { class TestClass {
5
1492
by: Bern McCarty | last post by:
We upgraded a bunch of MEC++ code to C++/CLI about 11 months ago and we've noticed that our images bloated quite a lot in the process. Upon investigating I observed that when a /clr compiland includes a header file for a native type that has an inlined copy constructor, that both the inlined copy constructor and the inlined destructor for that same type will end up in my mixed image, even though there is no reference made to that native...
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.