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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:05:37+00:00 2026-06-07T09:05:37+00:00

I have the following situation: I am using a third party .net library which

  • 0

I have the following situation:

I am using a third party .net library which calls into unmanaged code to do what it needs (the .net stuff is just a thin wrapper). That library has various IDisposable implementations etc which I am wrapping in usings but it still leaks memory like an, err, sieve I suppose (I have been able to prove this conclusively in a unit test).

Ideally of course I would get the third party to fix their library but they are not responsive and I, sadly, cannot drop it either so what I am currently doing is this…

The work I am doing with this third party library can be pretty easily encapsulated so where I need it I launch a process with a couple of command line arguments and capture the standard out. That process does what it needs to do and returns a result object by simply serialising it to the standard out whereupon the method in the launching application which kicked off the process deserializes the result object and returns it just as if nothing freaky has happened.

Obviously this is all pretty icky (command line argument parsing, serialising etc all adding complexity and slowing things down) but it has the advantage that it is pretty simple and it works (thankfully you can even turn off the window with CreateNoWindow so the user of the application doesn’t notice anything untoward either).

Other approaches I thought about:

  • Unloading app pools and whatnot but since the memory that is leaked is allocated outside of .net I figure that probably wouldn’t help or would it?
  • I also looked at trying to unload the DLL but it looks kind of fraught with danger – can I do this safely and reliably?

So, my question basically boils down to…

Is there a way that I could keep everything in process and somehow clean the bottom of this third party library for it so I do not leak memory?

  • 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-07T09:05:39+00:00Added an answer on June 7, 2026 at 9:05 am

    …it still leaks memory like an, err, sieve I suppose (I have been able to prove this conclusively in a unit test).

    I’m assuming the answer is ‘no’, but I have to ask — is there any chance it “leaks” memory
    during normal use, but is smart enough to clean it all up when you “shut it down”? I’ve encountered at least a few libraries whose internal caches seem to grow in an unbounded manner, but which get cleaned up when the library’s termination routine is invoked.

    Assuming the leaks are really just bugs, then…

    …where I need it I launch a process with a couple of command line arguments and capture the standard out

    …I think your approach here is the most reasonable one, given the parameters of the situation. In effect, you’re hosting code that you don’t “trust” — perhaps not for security reasons, but for performance / reliability reasons.

    Unloading app pools and whatnot but since the memory that is leaked is allocated outside of .net I figure that probably wouldn’t help or would it?

    Correct — that won’t help.

    I also looked at trying to unload the DLL but it looks kind of fraught with danger – can I do this safely and reliably?

    That most likely won’t solve the problem. If the code is as buggy as you say, it’s most likely not going to be good about cleaning up its allocated resources when it gets unloaded. (And the system isn’t going to clean up its resources for it either–if it allocated a resource without freeing it, that resource will effectively leak.)

    There’s really not much you can do otherwise in this case. The only last-resort option I can think of is trying to hook / intercept the 3rd-party library’s routines, somehow forcing all of its allocations into a pool that you can free all at once (after freeing the library). But you really shouldn’t try doing that. It’s quite dangerous, almost certainly not worth the effort, too hard to implement correctly, etc.

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

Sidebar

Related Questions

I have the following situation on my new ASP.Net page: I am using a
I am using the following situation: cmd.CommandText = insert into city (id, code, name,
I have following situation - Have a MongoService class, which reads host, port, database
I have the following situation: An Conversations entity/table which has multiple Tags associated to
I have the following situation: .net 3.5 WinForm client app accessing SQL Server 2008
I am using git version 1.7.2.3 and I have the following situation: Clone git
I have the following situation: using (SqlConnection conexao = new SqlConnection(ConnectionString)) { SqlCommand comando
I have the following situation: I have a work sheet which contains a list
I have the following situation: one activity (DateActivity) calls another activity (ListActivity) when a
I have the following situation: I have two threads thread1 , which is a

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.