Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 470083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:50:56+00:00 2026-05-12T23:50:56+00:00

I have a string that contains comma seperated email addresses. I then load this

  • 0

I have a string that contains comma seperated email addresses. I then load this into a string array, and from then populate a list which is easier to work with. Once the list is populated, I would like to be able to destroy the now unused string array, because the class still has a lot of work to do before the garbage collector will clean up this waste of memory.

How can I manually destroy this string array…

While reviewing the code, if you have a cleaner more efficient way of populating the list, recommendations are welcome.

Here is code:

  public class EmailReportManager
    {
        private List<string> emailAddresses;

        public EmailReportManager(string emailAddressesCommaSeperatedList)
        {
            loadAddresses(emailAddressesCommaSeperatedList);
        }

        private void loadAddresses(string emailAddressesCommaSeperatedList)
        {
            string[] addresses = emailAddressesCommaSeperatedList.Split(',');
            for (int addressCount = 0; addressCount < addresses.Length; addressCount++)
            {
                this.emailAddresses.Add(addresses[addressCount]);
            }
            //Want to destroy addresses here.....

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:50:57+00:00Added an answer on May 12, 2026 at 11:50 pm

    You can’t “destroy” the array. Options are:

    • You can clear the array using Array.Clear, so that it won’t hold references to any strings any more. This won’t reclaim any memory.
    • You can set the variable to null, so that that particular variable doesn’t prevent the array from being garbage collected. This won’t reclaim any memory.
    • You could call GC.Collect after making sure you don’t have any references to the array any more. This will probably reclaim the memory (it’s not guaranteed) but it’s generally not a good idea. In particular, forcing a full GC regularly can significantly harm performance.

    It’s worth understanding that in your case you don’t need to set the array variable to null – it’s about to go out of scope anyway. Even if it wasn’t about to go out of scope, if it wasn’t going to be used in the rest of the method (and the JIT could tell that) then setting it to null would be pointless. The GC can pretty reliably tell when a variable is no longer relevant. It’s rarely a good idea to set a variable to null for the sake of GC – if you find you want to, that’s usually an indication that you could refactor your code to be more modular anyway.

    It’s usually a good idea to just trust the GC. Why do you think the GC isn’t going to get round to reclaiming your array, and do you have a really good reason to care?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 269k
  • Answers 269k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It sounds like you have a sub-routine that is toggling… May 13, 2026 at 1:14 pm
  • Editorial Team
    Editorial Team added an answer <% i = 0 For Each IMAGE In IMAGES i… May 13, 2026 at 1:14 pm
  • Editorial Team
    Editorial Team added an answer It may be related to a bug with Git1.6.5.1 on… May 13, 2026 at 1:14 pm

Related Questions

So i am working with some email header data, and for the to:, from:,
I have a property IList CategoryIDs, and a private string variable that contains a
I have a DB table that contains a comma separated list of ID's (ints)
I have a method that needs to accept an array of country names, and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.