Results 1 to 9 of 9

Thread: does Useless Using Uses memory ?

  1. #1

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Unhappy 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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  2. #2
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: does Useless Using Uses memory ?

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

  3. #3

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: does Useless Using Uses memory ?

    Thanks !
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  5. #5

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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'.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: does Useless Using Uses memory ?

    Thanks guys !

    Edit: Damn ! Woosy and John, I can't rate you in this thread.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  9. #9

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: does Useless Using Uses memory ?

    I'm buying a new hard disk today. I'll get some free space to install Linux again.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width