---
title: "An interesting Memory Leak problem."
url: "https://osherove.com/blog/2004/7/11/an-interesting-memory-leak-problem.md"
canonical: "https://osherove.com/blog/2004/7/11/an-interesting-memory-leak-problem.html"
published: "2004-07-11T15:53:00"
updated: "2004-07-11T15:53:00"
tags: [".Net Quotations"]
author: "Roy Osherove"
description: "Udi is having a hard time figuring out a nasty weird memory leak problem . I have no idea what the answer is, but I'm sure one of you smart people out there could chime in. I'd love to see what the answer to this…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# An interesting Memory Leak problem.

By Roy Osherove July 11, 2004 In [.Net Quotations](https://osherove.com/blog/category/net-quotations)

**Historical article** · Originally published July 11, 2004; technical details may be outdated.

[Udi is having a hard time figuring out a nasty weird memory leak problem](http://udidahan.weblogs.us/archives/022452.html). I have no idea what the answer is, but I'm sure one of you smart people out there could chime in. I'd love to see what the answer to this problem is.

so - here's an exerpt that explains when the memory leak occurs and the explanation that is currenly suggested:

“_After asking around a bit, nobody could give me an explanation. Eventually, one of my programmers gave somebody a call, and he had an explanation. Now, this person could speak only Russian, so what I'm saying here comes via a second hand translation by my programmer (I don't speak any Russian). The reason he gave for this happening was that DLL's have a heap which is separate from that of the EXE, and that although structs are value types, they still have heap representation - they are objects that behave like primitives. Now, in cases when the thread is created within code from the DLL, automatic cleanup of memory allocated on the heap doesn't occur when using structs. When the thread is created within code from the EXE, the memory is automatically cleaned up._

_I had a hard time believing this, to say the least, but I couldn't find any other explanation. After checking it up a bit, and talking to some more people, I was still left high and dry. Everywhere I looked (and heard), there was no justification to his claim. However, by that exact same information, my problem shouldn't have been occurring._

_So, like I said before, the solution is to have the code that creates the threads on the EXE. If anyone can tell me why, I'd truly appreciate it - especially if you can find documentation supporting it :)_”

## More in .Net Quotations

[All posts in .Net Quotations](https://osherove.com/blog/category/net-quotations)

- Sep 3, 2004

    ### [Services without components on a pre-SP2 XP machine?](https://osherove.com/blog/2004/9/3/services-without-components-on-a-pre-sp2-xp-machine.html)

- Jul 17, 2004

    ### [Omer is doing some serious blogging](https://osherove.com/blog/2004/7/17/omer-is-doing-some-serious-blogging.html)

- Jun 11, 2004

    ### [Add Support for "Set" Collections to .NET](https://osherove.com/blog/2004/6/11/add-support-for-quotsetquot-collections-to-net.html)

- Jun 4, 2004

    ### [Method PageRank for Reflector](https://osherove.com/blog/2004/6/4/method-pagerank-for-reflector.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
