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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:58:57+00:00 2026-06-09T04:58:57+00:00

I am checking the memory usage of my service and found out that the

  • 0

I am checking the memory usage of my service and found out that the private bytes are increasing with time. The service creates the new components it requires and they only get disposed when the service stops. So I am searching for the code which creates new components when there is a service call and trying to dispose them when they are not required. I am using PerfMon to check the private bytes.

So am I on the right track till now?

Moreover, I have found that one of the method creates new struct every time and then its not gets disposed or assigned to null.

var structInfo = new MyStruct();
structInfo .StructSize = Marshal.SizeOf(structInfo);
MyClass info = this.BuildStructInfo(structInfo);
return info;

EDIT:

The method returns the class which gets its values from the struct.

Do I need to dispose the structInfo, will it be GC collected if I don’t do anything?

  • 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-09T04:58:58+00:00Added an answer on June 9, 2026 at 4:58 am

    A struct is a value type (like an int for example). It will be automatically be GC’ed if it goes out of scope.

    You could sometimes see the memory usage growing and growing, without any memory leak at all: if there is plenty of memory available, your GC won’t run that often.

    I suggest to use a memory profiler, which can show you why some objects are kept alive. I can recommend YourKit for .NET profiler, which has a 30-day free trial:

    • Start your application through YourKit
    • Take a memory snapshot
    • Search/browse for your classes you suspect to be leaking
    • Select path from GC-root
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question out of curiosity relating to checking for memory leaks. Being
I'm checking the memory usage of an application I've made. It makes numerous calls
By checking with valgrind, I see that 5 blocks of memory were not freed
I was checking out Intel's whatif site and their Transactional Memory compiler (each thread
Is there a way of checking if memory pointed to by pointer has been
I'm checking my code for memory leaks. Everything is okay until I got the
Checking few RDBMS I find that things like SELECT COUNT (a), SUM (b) FROM
Checking the documentation online I saw that it is pass by reference. Can someone
On Linux, FreeBSD and other systems I have valgrind for checking for memory errors
I have a very strange problem with memory leaks. I use _CrtDumpMemoryLeaks for checking

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.