Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Memory leak?  (Read 2410 times)

0 Members and 1 Guest are viewing this topic.

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Memory leak?
« on: April 20, 2014, 02:18:49 am »
Hello again.
I'm not sure where it should be placed so I just put it in general.

Today I found out that when I create and delete objects the memory begins to rise. Now I woldn't be surprised if it was everytime I delete an object (I'd just check my code for leaks) but it doesn't. As far as my tracking went I managed to find out that it has something to do with objects that have textures.

Now the strange thing is that VLD showed only 8 kb of memory leaked while Win7 task manager showed about 10 mb rising.

So is it false positive or is it an error in my code? I'm quite stuck here. Going to look further but would like to hear some ideas.
« Last Edit: April 20, 2014, 02:54:14 am by JunkerKun »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Memory leak?
« Reply #1 on: April 20, 2014, 09:04:07 am »
It's usually a driver issue. 100% of memory leaks reports on SFML so far ended up being one.
Laurent Gomila - SFML developer

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Memory leak?
« Reply #2 on: April 20, 2014, 10:17:21 am »
It's usually a driver issue. 100% of memory leaks reports on SFML so far ended up being one.

Hmm.. going to update my driver and check if it has an effect.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Memory leak?
« Reply #3 on: April 20, 2014, 10:46:58 am »
If you show us some code, maybe even a minimal example that we can try ourselves that reproduces the problem, then we might be able to suggest ways to mitigate the leaking. That the drivers leak is a fact (even with the most up to date ones), you just have to know when they do and try to avoid/reduce doing whatever it is that causes it.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

JunkerKun

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: Memory leak?
« Reply #4 on: April 20, 2014, 11:44:36 am »
If you show us some code, maybe even a minimal example that we can try ourselves that reproduces the problem, then we might be able to suggest ways to mitigate the leaking. That the drivers leak is a fact (even with the most up to date ones), you just have to know when they do and try to avoid/reduce doing whatever it is that causes it.

Well, that is the problem. The leak seems to be occuring when I create a texture but... with the same circumstances but different texture it does not leak (or at least it doesn't show up on "radars")! I'm really confused by this.
Aaaaaand... the code would be too long to post. Besides I still need to trace the exact location where it occurs. I will update when I find at least something.

Update:
Here is the fun thing: lesser a texture is, more noticable the leak becomes. I'm begining to think it is indeed a leak in the driver, not in my code. Can't be too sure though.
« Last Edit: April 20, 2014, 11:57:17 am by JunkerKun »

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: Memory leak?
« Reply #5 on: April 23, 2014, 06:30:48 pm »
debug your code and post the function that pointers can't be deleted and we'll fix that for you
i have a recommendation:
use malloc and free
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10829
    • View Profile
    • development blog
    • Email
Re: Memory leak?
« Reply #6 on: April 23, 2014, 06:51:56 pm »
i have a recommendation:
use malloc and free
No! I can't even... ::)
Use RAII and don't bother about memory management anymore.

Aaaaaand... the code would be too long to post.
If the code is too long to post, then I'm 99.999999999999999999999% sure it's not SFML's fault, because memory leaks are nearly always reproducible in a very small example.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Memory leak?
« Reply #7 on: April 23, 2014, 06:58:03 pm »
...
i have a recommendation:
use malloc and free
Are you serious?
You are aware that malloc doesn't call constructors and free doesn't call destructors - right?
Also, as has already been mentioned, with modern C++ and RAII it's extremely rare that you have to deal with manual memory management at all.

 

anything