Results 1 to 3 of 3

Thread: [RESOLVED] Which is more overhead

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] Which is more overhead

    hi,

    I have 2 classes can you tell which class is better in memory management?

    Code:
    class class1
    {
      private dataset mydataset = null;
       
      public void func1()
      {
         mydataset = new dataset()
         //code here
      }
      public void func2()
      {
         mydataset = new dataset()
         //code here
      }
    
      public void func3()
      {
         mydataset = new dataset()
         //code here
      }   
      
    }
    vs


    Code:
    class class2
    {   
      public void func1()
      {
         dataset mydataset = new dataset()
         //code here
      }
      public void func2()
      {
        dataset  mydataset = new dataset()
         //code here
      }
    
      public void func3()
      {
         dataset mydataset = new dataset()
         //code here
      }   
      
    }


    Thanks,
    Popskie

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

    Re: Which is more overhead

    There's virtually no difference, only a few bytes for the variable. The number of DataSet objects is exactly the same so the actual variables will make no difference. The only possible difference would be with the first one if you didn't set your mydataset variable to null at the end of each call its memory could not be reclaimed until another method was called.
    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

  3. #3

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: Which is more overhead

    Sorry JM for my question. I know how to code the problem is I dont know whats happen during runtime. Again JM thanks, I marked this thread as resolved.

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