# Severe memory leakage since Xojo 2013 related to frequently opening windows

**URL:** <https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398>\
**Category:** macOS\
**Created:** [January 8, 2017, 3:10pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398 "2017-01-08T15:10:24Z")\
**Posts on this page:** 15\
**Page:** 2

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [January 8, 2017, 7:52pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/21 "2017-01-08T19:52:45Z")

</div>

It probably means the larger the window the larger the leak as well. Ouch.

---

<div class="post-metadata">

**Author:** ![Ulrich\_Bogun](https://forum.xojo.com/user_avatar/forum.xojo.com/ulrich_bogun/32/1864_2.png) [@Ulrich\_Bogun](https://forum.xojo.com/u/Ulrich_Bogun)\
**Post date:** [January 8, 2017, 7:57pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/22 "2017-01-08T19:57:26Z")

</div>

I could not verify that, but I havent tested that intensively.

---

<div class="post-metadata">

**Author:** ![James\_Sentman](https://forum.xojo.com/user_avatar/forum.xojo.com/james_sentman/32/742_2.png) [@James\_Sentman](https://forum.xojo.com/u/James_Sentman)\
**Post date:** [January 8, 2017, 8:50pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/23 "2017-01-08T20:50:20Z")

</div>

> [@308667:@Ulrich Bogun](#):
>
> Yes. Thats why the release trick does not work. That was fixes but somehow replaced by the new leak.

So the forced release in the close event doesnt work to solve this anymore? Yikes… I need to investigate that.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [January 9, 2017, 8:16am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/24 "2017-01-09T08:16:52Z")

</div>

I just entered a sample project to show problem and I can reproduce it:

\<[https://xojo.com/issue/46549](https://xojo.com/issue/46549)\>

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [January 9, 2017, 9:45am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/25 "2017-01-09T09:45:06Z")

</div>

> [@308644:@scott boss](#):
>
> On Windows and Mac what are the best ways to determine if there is a memory leak?

On the Mac, Open Activity Monitor, select your app’s process and click the (i) button. Then watch the “Real memory” and “virtual memory” sizes. If they constantly go up, you’re likely to have a leak.

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [January 9, 2017, 10:11am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/26 "2017-01-09T10:11:59Z")

</div>

I have attached another test project to Christian’s report (\<[https://xojo.com/issue/46549](https://xojo.com/issue/46549)\>) that demonstrates the issue more clearly. It opens and closes a window frequently, using a Timer, while showing the app’s used memory. That goes up by about one MB per second, and will crash eventually due to all VM used up. That’s the bug I was talking about.

So, my suspicion about a bad memory allocation scheme does not seem to be the cause, which is a relief. It’s just a simple leak, after all.

In fact, the bug report Norman pointed out seems to be the same, so Christian’s can be merged with \<[https://xojo.com/issue/43484](https://xojo.com/issue/43484)\>.

And the release call inside CancelClose seems still to work - at least in my test, it does. Mostly.

I still see a smaller leak with the work-around, but it’s much better than currently. I still hope the leaks are all fixed sooner than later. I can’t have my app (which runs all the time in the background, i.e. never gets quit, ideally) crash after a few days or weeks of running because it’s running out of memory due to such leaks.

---

<div class="post-metadata">

**Author:** ![Carlo\_Rubini](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/94ad74/32.png) [@Carlo\_Rubini](https://forum.xojo.com/u/Carlo_Rubini)\
**Post date:** [January 9, 2017, 10:24am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/27 "2017-01-09T10:24:51Z")

</div>

There is also the following Feedback Case that doesn’t benefit by the workaround of Feedback Case #43484.  
Feedback Case #42044 - Closing a window containing pagepanel does not release memory usage

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [January 9, 2017, 10:27am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/28 "2017-01-09T10:27:50Z")

</div>

Well, there are probably 10 cases related.

And it’s important to have each with a sample project.  
Now Xojo engineers can fix the NSWindow leak and than run all those test projects and see if things get better.  
And than mark all those cases as fixed or not.

Because there may be other leaks!  
The page panel one could be the same NSWindow leak or a different one!

---

<div class="post-metadata">

**Author:** ![Thomas\_Tempelmann](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_tempelmann/32/315_2.png) [@Thomas\_Tempelmann](https://forum.xojo.com/u/Thomas_Tempelmann)\
**Post date:** [January 9, 2017, 10:40am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/29 "2017-01-09T10:40:07Z")

</div>

I am still curious why the Virtual Memory raises so quickly to 4 GB due to this leak even though the Real Memory usage stays around 1 GB.

That still suggests a memory fragmentation issue, so I still like to get an answer on my original suspicion that Xojo has its own memory pool.

If that’s the case, then this suggests that it’s not using and freeing those pools properly. By that I mean that there are common optimizations for memory pools, and one is to re-use the last freed block. That method would be wrong in this case because that will lead to the fragmentation I’m seeing! Instead, a second-level pool (like I suspect Xojo is using) needs to try to prefer the older pools for re-allocation so that younger pools can be kept as empty as possible, and returned to the system pool ASAP when they’re empty again. This will make allocations a bit slower but will prevent the fragmentation issue I am seeing. And it would be only necessary to do this in 32 bit apps. In 64 bit apps, the VM space is large enough so that fragmentation won’t be an issue as long as the pool sizes are aligned with VM page sizes.

Can someone from Xojo with some insight in the memory management comment on this, please? (Am I even being understood or am I not making sense? I can elaborate this with examples if it helps. But getting no answer at all only indicates that either there’s no time to even look at this - which would be worrysome - or that no one thinks I have a valid point, which would be even worse.)

---

<div class="post-metadata">

**Author:** ![Carlo\_Rubini](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/94ad74/32.png) [@Carlo\_Rubini](https://forum.xojo.com/u/Carlo_Rubini)\
**Post date:** [January 9, 2017, 10:45am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/30 "2017-01-09T10:45:53Z")

</div>

@Christian Schmitz [quote]The page panel one could be the same NSWindow leak or a different one![/quote]  
I recall Joe saying that the page panel leak is probably different than NSWindow leak. That’s why I opened a new case for it.

---

<div class="post-metadata">

**Author:** ![Mike\_D](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_d/32/266_2.png) [@Mike\_D](https://forum.xojo.com/u/Mike_D)\
**Post date:** [January 9, 2017, 3:14pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/31 "2017-01-09T15:14:37Z")

</div>

Do you use IPCSockets? I found a bad leak \<[https://xojo.com/issue/34107](https://xojo.com/issue/34107)\>

---

<div class="post-metadata">

**Author:** ![Joseph\_Claeys](https://forum.xojo.com/user_avatar/forum.xojo.com/joseph_claeys/32/1104_2.png) [@Joseph\_Claeys](https://forum.xojo.com/u/Joseph_Claeys)\
**Post date:** [January 10, 2017, 5:23pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/32 "2017-01-10T17:23:18Z")

</div>

[quote=308748:@Christian Schmitz]I just entered a sample project to show problem and I can reproduce it:

\<[https://xojo.com/issue/46549](https://xojo.com/issue/46549)\>[/quote]

Only ranked 169th in the Feedback app. This seems really problematic for some apps. Lets shine some light on it.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [January 15, 2017, 9:46am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/33 "2017-01-15T09:46:19Z")

</div>

Thomas,

this may (is certainly not) related to your finding, but Firefox leaks 20MB by downloaded file (checked with theActivity Monitor) when I download more than 1 file at a time. This explain a bit why after some hours I get Firefox working from slow to slower. It does not explain everything, but this is a huge discovery. Quit and Fire set the memory footprint back to default, but the leak restart as soon as I download more than a file at a time.

This may also explain why I have troubles when Xojo runs and Firefox too. (I am not sure of the cause, but I get the effects)

---

<div class="post-metadata">

**Author:** ![Richard\_Duke](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_duke/32/246_2.png) [@Richard\_Duke](https://forum.xojo.com/u/Richard_Duke)\
**Post date:** [January 15, 2017, 10:17am UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/34 "2017-01-15T10:17:11Z")

</div>

> [@308763:@Thomas Tempelmann](#):
>
> On the Mac, Open Activity Monitor, select your app’s process and click the (i) button. Then watch the “Real memory” and “virtual memory” sizes. If they constantly go up, you’re likely to have a leak.

on Sierra, i don’t see Virtual Memory in the list of value after doing a right click.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:36pm UTC](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398/35 "2020-10-29T18:36:31Z")

</div>



[Previous page](https://forum.xojo.com/t/severe-memory-leakage-since-xojo-2013-related-to-frequently-opening-windows/35398.md?page=1)
