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

Home Posts Topics Members FAQ

/CLR bloats image with unreferenced code in VC8

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 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 unmanaged 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.

Can someone from Microsoft please comment on this problem?

Bern McCarty
Bentley Systems, Inc.
Nov 12 '07 #1
5 1492

"Bern McCarty" <be*****@newsgr oup.nospamwrote in message
news:60******** *************** ***********@mic rosoft.com...
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 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 unmanaged 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.

Can someone from Microsoft please comment on this problem?
Others have mentioned this behavior before, that unused native types end up
in the final image. I suspect that is an inadvertant result of a design
choice to not remove unused managed types (they could still be used through
reflection, after all), possibly combined with the metadata generated even
for native types.

I suggest that you file a bug on Microsoft Connect, and include real code
for your "trivial" reproduction.
>
Bern McCarty
Bentley Systems, Inc.


Nov 12 '07 #2
Hi Bern,

Do you mean something like this? We can't seem to get it to repro with my
simple repro.

D:\repro\unref_ code_managed>ty pe myheader.h
#include <stdio.h>

#pragma managed(push, off)
__declspec(dlli mport) void SomethingFromDl l();

class Foo
{
public:
Foo()
{
printf("Foo ctor()");
}
Foo(const Foo& rhs)
{
printf("Foo copy-ctor()");
}
void doSomething()
{
SomethingFromDl l();
}
~Foo()
{
SomethingFromDl l();
printf("Foo dtor()");
}
};

#pragma managed(pop)

D:\repro\unref_ code_managed>ty pe t.cpp
#include <stdio.h>
#include "myheader.h "

void main()
{
printf("Hello world!");
}

D:\repro\unref_ code_managed>cl t.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for
80x86

Copyright (C) Microsoft Corporation. All rights reserved.

t.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.

/out:t.exe
t.obj

D:\repro\unref_ code_managed>t
Hello world!
D:\repro\unref_ code_managed>cl /clr t.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762
for Microsoft (R) .NET Framework version 2.00.50727.1302
Copyright (C) Microsoft Corporation. All rights reserved.

t.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.

/out:t.exe
t.obj

D:\repro\unref_ code_managed>t
Hello world!
D:\repro\unref_ code_managed>

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 14 '07 #3
Hi Bern,

Have you reviewed my reply to you? Can you provide more details to help me
reproduce this problem? Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 16 '07 #4
Hi Jeff,

Yeah that's the idea. I tried your example with the same result (no repro)
so then I preproc'd one of our real header files and modified your example
to use it and then I was able to get an unresolved external link error (but
only with /CLR added). The preproc'd header is pretty big. Can you give me a
place to upload the repro?

-Bern
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:WC******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Bern,

Have you reviewed my reply to you? Can you provide more details to help me
reproduce this problem? Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
Nov 16 '07 #5
Hi Bern,

Thanks for your feedback.

MSDN newsgroup support policy normally does not cover very large production
code. Microsoft CSS phone support is more suitable for large file
troubleshooting .

Anyway, if you want I will try my best to help you. You may attach the file
as an attachment through Outlook Express or you may email it to me at:
je***@online.mi crosoft.com(remove "online."). Please also provide the
detailed steps to use this file and for reproducing. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 19 '07 #6

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

Similar topics

1
2194
by: Mike | last post by:
I want to change the background image of the html page within code based on the users selection. I'm trying to use this in the page onload even response.write("<body background=' & dataitem>") but i can't get it to work. if i hard code the dataitem in it will change but i need it to work with the item being passed in.
3
8801
by: Shawn | last post by:
Hi. I have an asp:table, like this: <asp:Table runat="server" id="Table1"> <asp:TableRow Runat="server"> <asp:TableCell id="tc1" Runat="server">&nbsp;</asp:TableCell> <asp:TableCell id="tc2" Runat="server">&nbsp;</asp:TableCell> </asp:TableRow> </asp:Table>
1
5954
by: Geuis | last post by:
Hi, new to the group. I use the following code to resize images my users upload. They're either blurry or they're jaggy. Can someone recommend modifications or different code that will resize images smoothly? $o_file = $_GET;
15
5939
by: mistral | last post by:
I want find code for clickable thumbnails, when click on small picture, a big image will popup in new window, sized to fit picture. Same as standard javascript image previewer, but without using javascript. I want try do this with html only, that this work on browsers with javascript disabled. I tried the following, but it still require javascript enabled to show popup resized to fit image, otherwise it open a fullscreen window. <a...
2
2414
by: corymac | last post by:
Hello, I've customized the panview code to accommodate what I want it to do, but I'm having a problem with it in IE. Firefox works fine. Panning the image in IE doesn't work and I think it has something to do with scrollTop, but i have no idea what to do to fix it. If I take the pan image code out of the html page and have it by itself it works.
1
1452
by: Bern McCarty | last post by:
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...
2
1901
by: casybay | last post by:
Hi all, I am going to interpret a picture which I have done the enhancement and segmentation. It is a picture of several flowers (in a round shape). I am thinking to catalog them into shapes (i.e.,calculate how many circles in the picture). My program of enhancement and segmentation is written in JAVA, so I will keep using JAVA for interpretation. Since the techniques of image interpretation is so abstract, I have no idea what algorithm...
1
4884
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop program,which can upload many file in folder.problem is,am unable to save my file name in to database.because i used same name for all input file type as file. i dont know get name of file.below i presented my coding for ur view.fed up with my coding..pls...
4
1653
by: Zarich | last post by:
This is a part of a code that i use to upload a video and a picture,but i want to modify the img part to upload the file in a diferent folder and i don't want it to create an unique folder for each picture. <tr> <td>Selecciona la imagen que representara el video :<div class="upload_sub">Esta sera la imagen que visualizaran los usuarios, debe ser un screenshot del video a subir.</div></td> <td> ...
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
10302
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
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.