|
-
Mar 16th, 2006, 08:55 AM
#1
does Useless Using Uses memory ?
If I refer a namespaces in a program, but don't use anything from that namespace, will it waste memory ?
Last edited by iPrank; Mar 16th, 2006 at 03:35 PM.
-
Mar 16th, 2006, 10:03 AM
#2
Hyperactive Member
Re: does Useless Using Uses memory ?
 Originally Posted by iPrank
If I refer a namespaces in a program, but don't use anything from that namespace, will it waste memory ?
Yes, but a minimal amount at runtime. The only real penalty is if you reference lots of unneeded namespaces intelisense will take a while to populate in the DE.
-
Mar 16th, 2006, 02:39 PM
#3
Re: does Useless Using Uses memory ?
Thanks !
-
Mar 16th, 2006, 03:07 PM
#4
Re: [RESOLVED] does Useless Using Uses memory ?
As I understand the compiler strips out unreferenced namespaces so the EXE is as clean as possible. Using statements are only used by the c# preprocesor.
I don't live here any more.
-
Mar 16th, 2006, 03:31 PM
#5
Re: does Useless Using Uses memory ?
OK. I'm confused. 
I searched google, but didn't find anything usefull.
PS: I've made this thread 'unresolved'.
-
Mar 16th, 2006, 06:05 PM
#6
Re: does Useless Using Uses memory ?
As far as I'm aware the "using" statement only affects the design time experience. It allows you to refer to types in your code without qualifying them with their namespace. Once your code is compiled that makes no difference because the MSIL will be the same regardless of whether you have qualified your types or not. It is referencing assemblies that may cause an issue. If you add a reference to your project to an assembly then that assembly will be loaded at run time. If you don't use any types from that assembly then you've wasted the memory it's occupying. It may be that the compiler is smart enough to remove unused references but I'm not sure if that's the case. Perhaps that's what wossname was referring to. Namespaces and assemblies are not the same thing though. A namespace is just a logical classification of types and doesn't actually exist in any particular place. A single namespace may be spread over more than one assembly.
-
Mar 17th, 2006, 12:30 AM
#7
Re: does Useless Using Uses memory ?
Thanks guys !
Edit: Damn ! Woosy and John, I can't rate you in this thread.
-
Mar 20th, 2006, 04:31 PM
#8
Re: does Useless Using Uses memory ?
Hopefully I'll be using Mono in linux soon so can once again join in the fun of C# coding at home as well as at work.
I don't live here any more.
-
Mar 20th, 2006, 08:05 PM
#9
Re: does Useless Using Uses memory ?
I'm buying a new hard disk today. I'll get some free space to install Linux again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|