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 65847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:00:38+00:00 2026-05-10T19:00:38+00:00

I have a problem with a memory leak in a .NET CF application. Using

  • 0

I have a problem with a memory leak in a .NET CF application.

Using RPM I identified that dynamically creating controls are not garbage collected as expected. Running the same piece of code in .NET Window Forms behave differently and disposes the control as I expected.

See the output from RPM via PerfMon for the Process Heap counter:
alt text

GC Heap:
alt text

My best guess is that the Weak Reference to the Panel is for some unknown reason not making the object eligible for GC, can it be?

Please note: Even though Dispose() solves the problem for the sample, I can’t easily incorporate it into the existing application as it is not as clear cut to determine when the object is no longer in use.

I have included a simplified version of the source to illustrate the problem:

using System; using System.Windows.Forms;  namespace CFMemTest {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }          // Calling this event handler multiple times causes the memory leak         private void Button1_Click(object sender, EventArgs e)         {             Panel uc = new Panel();             // Calling uc.Dispose() cleans up the object          }     } } 

Update:
1. Calling GC.Collect() also doesn’t result in the panels being cleaned up.
2. Using .NET CF 2.0 SP1 on a Windows CE 4.2 device.

  • 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. 2026-05-10T19:00:39+00:00Added an answer on May 10, 2026 at 7:00 pm

    Some additional information here that explains this behaviour.

    According to Ilya Tumanov:

    Everything UI related on NETCF is intentionally removed from GC scope so it is never collected. This behavior is different from desktop and has been changed in NETCF V3.5 (unless running in compatibility mode).

    It is so different because managed UI classes on NETCF are completely different from desktop. They are thin wrappers over native implementation which was needed to achieve acceptable performance.

    I’m not sure there’s such a resource. But really, all you need to know is: it’s never collected, must call dispose. You actually should do that on desktop as well but if you don’t its way more forgiving. Not so on NETCF.

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

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • 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 There is a property in Environment class that tells about… May 11, 2026 at 8:08 pm
  • Editorial Team
    Editorial Team added an answer You're looking for a double-ended queue. This is implemented the… May 11, 2026 at 8:08 pm
  • Editorial Team
    Editorial Team added an answer DdlUtils has what you're looking for. You can read/write schemas… May 11, 2026 at 8:08 pm

Related Questions

I appear to have a memory leak in this piece of code. It is
I have a huge web app that is having issues with memory leak in
I'm having a problem with an application hanging and giving me the default Please
Okay, so I have two classes, call them A and B--in that order in

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.