# Problem of memory leaks

**URL:** <https://forum.juce.com/t/problem-of-memory-leaks/12346>\
**Category:** General JUCE discussion\
**Created:** [February 8, 2014, 12:39pm UTC](https://forum.juce.com/t/problem-of-memory-leaks/12346 "2014-02-08T12:39:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ostrovitch](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@ostrovitch](https://forum.juce.com/u/ostrovitch)\
**Post date:** [February 8, 2014, 12:39pm UTC](https://forum.juce.com/t/problem-of-memory-leaks/12346/1 "2014-02-08T12:39:14Z")

</div>

Hi,

I'm using Juce modules 3.0.2, with visual studio 2013 on windows7.

I experienced recently some memory leaks detections from Visual Studio.

When I execute my program in debug mode and when it stops, visual studio reports some memory leaks.

Since many days I tried to bypass many part of my code to try to identify what part could generate it, without success.

At the same time my code is very simple and I really dont see what could make such events happen.

&nbsp;

So, I tried something else. I ran JuceDemo in debug mode, inside visual studio 2013.

1) I run JuceDemo and I close it. -\> No memory leaks.

2) I run JuceDemo, I click on "tabs and widgets" then I close it, here is what I get:

```
'JuceDemo.exe' (Win32) : Déchargé 'C:\Windows\System32\d3d10warp.dll'
'JuceDemo.exe' (Win32) : Déchargé 'C:\Windows\System32\DWrite.dll'
'JuceDemo.exe' (Win32) : Déchargé 'C:\Windows\System32\d2d1.dll'
'JuceDemo.exe' (Win32) : Déchargé 'C:\Windows\System32\d3d11.dll'
'JuceDemo.exe' (Win32) : Déchargé 'C:\Windows\System32\dxgi.dll'
Detected memory leaks!
Dumping objects ->
{92771} normal block at 0x00000000068A2840, 35 bytes long.
 Data: < > 00 00 00 00 CD CD CD CD 0C 00 00 00 00 00 00 00 
{92770} normal block at 0x00000000068A27C0, 16 bytes long.
 Data: <P( IB > 50 28 8A 06 00 00 00 00 10 0D 49 42 08 00 00 00 
{92761} normal block at 0x00000000068A24E0, 27 bytes long.
 Data: < > 00 00 00 00 CD CD CD CD 04 00 00 00 00 00 00 00 
{92760} normal block at 0x00000000068A2460, 16 bytes long.
 Data: < $ 4 A > F0 24 8A 06 00 00 00 00 34 E3 A7 41 03 00 00 00 
{92756} normal block at 0x00000000068A23E0, 27 bytes long.
 Data: < > 00 00 00 00 CD CD CD CD 04 00 00 00 00 00 00 00 
{92755} normal block at 0x00000000068A2360, 16 bytes long.
 Data: < # @ > F0 23 8A 06 00 00 00 00 1F 98 81 40 01 00 00 00 
{92751} normal block at 0x00000000068A22D0, 31 bytes long.
 Data: < > 00 00 00 00 CD CD CD CD 08 00 00 00 00 00 00 00 
{92750} normal block at 0x00000000068A2250, 16 bytes long.
 Data: < " A > E0 22 8A 06 00 00 00 00 D7 0F B6 41 04 00 00 00 
{92746} normal block at 0x00000000068A21D0, 27 bytes long.
 Data: < > 00 00 00 00 CD CD CD CD 04 00 00 00 00 00 00 00 
{92745} normal block at 0x00000000068A2150, 16 bytes long.
 Data: < ! @ > E0 21 8A 06 00 00 00 00 1F 98 81 40 01 00 00 00 
{92740} normal block at 0x00000000068A2010, 35 bytes long.
 Data: < > 00 00 00 00 CD CD CD CD 0C 00 00 00 00 00 00 00 
{92739} normal block at 0x00000000068A1F90, 16 bytes long.
 Data: < tB > 20 20 8A 06 00 00 00 00 91 EC 74 42 0B 00 00 00 
Object dump complete.
Le thread 0x1d7c s'est arrêté avec le code 0 (0x0).
Le thread 0x1338 s'est arrêté avec le code 0 (0x0).
Le programme '[0x1F88] JuceDemo.exe' s'est arrêté avec le code 0 (0x0).
```

I tried making&nbsp;the file name and the line appear with&nbsp;\_CRTDBG\_MAP\_ALLOC but it's a nightmare to get it works,

I nevery succeded. I tried to put some&nbsp;\_CrtSetBreakAlloc(...) for it stops when the object is allocated, but I get some&nbsp;breakpoints

inside JUCE modules, I can't explain. For example the&nbsp;\_CrtSetBreakAlloc(...) generates a breakpoint on&nbsp;

&nbsp;

```
JUCEApplication::getInstance()->quit();
```

&nbsp;

It would mean the object is allocated by this statement.

Of course I could ignore these memory leaks, as my program seems doing what it's supposed to do, but I don't feel so safe.

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [February 8, 2014, 1:20pm UTC](https://forum.juce.com/t/problem-of-memory-leaks/12346/2 "2014-02-08T13:20:43Z")

</div>

No such leaks for me when I run the demo.. (?)

---

<div class="post-metadata">

**Author:** ![ostrovitch](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@ostrovitch](https://forum.juce.com/u/ostrovitch)\
**Post date:** [February 8, 2014, 1:33pm UTC](https://forum.juce.com/t/problem-of-memory-leaks/12346/3 "2014-02-08T13:33:00Z")

</div>

It happens when I use the following options of the demo:

System Info  
Tabs & Widgets  
Live Constant -\> click on Begin Demo  
MDI  
Transforms  
Web Browser  
Fonts  
Settings  
Latency Detector  
Cryptography  
HTTP  
Javascript  
Unit Tests  
  
It occurs when I run it in debug mode, and it's compiled in 64bits mode, but I tried in 32bits mode, I get&nbsp;the same problem.

&nbsp;

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [February 8, 2014, 3:44pm UTC](https://forum.juce.com/t/problem-of-memory-leaks/12346/4 "2014-02-08T15:44:42Z")

</div>

It could just be a couple of undelivered messages on the message queue that didn't arrive before the app shutdown, but I really don't know, and like I said, I can't reproduce it..

---

<div class="post-metadata">

**Author:** ![ostrovitch](https://avatars.discourse-cdn.com/v4/letter/o/bc79bd/32.png) [@ostrovitch](https://forum.juce.com/u/ostrovitch)\
**Post date:** [February 8, 2014, 4:06pm UTC](https://forum.juce.com/t/problem-of-memory-leaks/12346/5 "2014-02-08T16:06:49Z")

</div>

Thanks.

So I just downloaded the last Juce modules. (My previous version was downloaded about 2 weeks before)

And now Juce Demo never issue any memory leaks after quit.

Though my program still does. Maybe it's because I call JUCEApplication::getInstance()-\>quit() inside the initialise method

of my application, I'll try to dig.
