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

  • Home
  • SEARCH
  • 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 8092915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:23:20+00:00 2026-06-05T20:23:20+00:00

I have a simple WCF service hosted in IIS7 using the HTTP protocol. The

  • 0

I have a simple WCF service hosted in IIS7 using the HTTP protocol. The service contains a method which returns a custom object called Calendar. This object is very basic, and contains simple value-type properties, with the exception of one property, Holidays, which is of type List<IHoliday>. Holiday is again, a simple type comprised of value-type properties only.

The Calendar object is returned from the WCF service-method to an MVC controller, and is applied to a corresponding view. During memory-testing using dotTrace, it’s apparent that the Calendar object is finalised by the GC, but interestingly, its Holidays property, which is empty, remains on the heap.

It’s not a major performance-issue, taking up a mere 32 bytes, but I’m interested to know why the empty list is not disposed. I can provide code-samples, if necessary.

Source code and service configuration below:

public class Calendar : ICalendar
{
    [DataMember] private IEnumerable<IHoliday> holidays = new List<IHoliday>();
    [DataMember] private IEnumerable<IHolidayNotTaken> holidaysNotTaken = new List<IHolidayNotTaken>();
    [DataMember] private IEnumerable<INonInstructionalDay> nonInstructionalDays = new List<INonInstructionalDay>();
    [DataMember] private IEnumerable<ISchoolBreak> schoolBreaks = new List<ISchoolBreak>();
}

public class Holiday : IHoliday, IIdentifiable, IDisposable
{
    [DataMember(Name = @"date")] [JsonProperty(PropertyName = @"date")] private string date;

    [DataMember(Name = @"checked")]
    [JsonProperty(PropertyName = @"checked")]
    public bool Checked { get; set; }

    /// <summary>
    ///   Gets or sets the end Holiday Id.
    /// </summary>
    /// <value> The holiday id. </value>
    [DataMember(Name = @"id")]
    [JsonProperty(PropertyName = @"id")]
    public int HolidayId { get; set; }

    /// <summary>
    ///   Gets or sets the end description for the holiday.
    /// </summary>
    /// <value> The description. </value>
    [DataMember(Name = @"description")]
    [JsonProperty(PropertyName = @"description")]
    public string Description { get; set; }

    /// <summary>
    ///   Gets or sets the date of the holiday.
    /// </summary>
    /// <value> The holiday date. </value>
    [DataMember]
    [JsonIgnore]
    public DateTime Date { get; set; }

    /// <summary>
    ///   Gets or sets the sort order for the holiday.
    /// </summary>
    /// <value> The sort order. </value>
    [DataMember(Name = @"sortOrder")]
    [JsonProperty(PropertyName = @"sortOrder")]
    public int SortOrder { get; set; }

    /// <summary>
    ///   Gets the <see cref="IIdentifiable.Type" /> of this instance.
    /// </summary>
    [DataMember(Name = @"type")]
    [JsonProperty(PropertyName = @"type")]
    public string Type { get; private set; }

    /// <summary>
    ///   Invoked when this instance is serialising.
    /// </summary>
    /// <param name="streamingContext"> The streaming context. </param>
    [OnSerializing]
    private void OnSerialising(StreamingContext streamingContext)
    {
        date = Date.ToString(@"yyyy-MM-dd");
        Type = GetType().ToString();
    }
}

Service Method:

public Domain.Calendar GetCalendarByMember(string externalId)
    {
        try
        {
            using (var e = new EPlannerEntities())
            {
                var memberId = e.Members
                    .Where(m => m.ExternalId == externalId)
                    .Select(m => m.MemberId)
                    .SingleOrDefault();

                if (memberId.Equals(0))
                {
                    e.Members.AddObject(new Member { ExternalId = externalId.Trim() });

                    var calendar = new Domain.Calendar
                                   {
                                       DefaultViewId = 2,
                                       MemberId = memberId,
                                       IsWeekendsVisible = true,
                                       TimeFormatId = 1,
                                       DayBeginTime = new TimeSpan(0, 8, 0, 0),
                                       DayEndTime = new TimeSpan(0, 16, 0, 0),
                                       DateFormatId = 1
                                   };

                    e.Calendars.AddObject(calendar);
                    e.SaveChanges();

                    return calendar;
                }

                return e.Calendars.Single(c => c.MemberId == memberId);
            }
        }
        catch (Exception exception)
        {
            throw ErrorManager.FaultException(ExceptionType.Business, (int) CalendarErrorCodes.GeneralError, exception);
        }
    }

Service Configuration:

<services>
  <service behaviorConfiguration="CalendarServiceBehavior" name="HMH.ePlanner.Services.Calendar">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="TCPBinding" name="TCPEndPoint" contract="HMH.ePlanner.Services.ICalendar">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="HTTPBinding" name="HttpEndPoint" contract="HMH.ePlanner.Services.ICalendar" />
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" name="TCPMexEndPoint" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:808/Calendar.svc" />
      </baseAddresses>
    </host>
  </service>
</services>
  • 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-06-05T20:23:21+00:00Added an answer on June 5, 2026 at 8:23 pm

    The problem stems from the fact that the Holiday list is instantiated without specifying an UpperBound. Specifying an UpperBound ensures that the object is removed from the Heap after garbage-collection.

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

Sidebar

Related Questions

I have a WCF-REST service with one method which returns a string: [ServiceContract] public
I have a simple WCF service hosted in IIS7.5 exposed over a wsHttp binding
I have a simple .NET 4 WCF service which I have hosted locally on
I have a simple WCF Web service. It's hosted on IIS under the default
I have a simple WCF service hosted in a console app and what I
System Description: I have a WCF service (self hosted in a windows service) which
I have simple WCF service hosted on Windows Service. When the client of wcf
I have a WCF service hosted in IIS7.5 running as a specific domain account.
I have a simple WCF service (hosted as its own site in IIS). It
I have a simple WCF service hosted in a windows service. The service itself

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.