# Memory leak

**URL:** <https://forum.kirupa.com/t/memory-leak/286150>\
**Category:** Uncategorized\
**Created:** [April 10, 2009, 8:27pm UTC](https://forum.kirupa.com/t/memory-leak/286150 "2009-04-10T20:27:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [April 10, 2009, 8:27pm UTC](https://forum.kirupa.com/t/memory-leak/286150/1 "2009-04-10T20:27:13Z")

</div>

If I were to run this code, would the program create hundreds of pointers? (I am aware that only one singleton will be created).

```php

while(true)
{
    ClassName* instanceName = ClassName::getSingleton();
}

```

Someone told me that if I wanted to only wanted to create the pointer on the first iteration of the while loop, I would have to change it to:

```php

while(true)
{
    static ClassName* instanceName = ClassName::getSingleton();
}

```

Is that true?
