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

Author Topic: Possible Memory Leak SocketSelector  (Read 3448 times)

0 Members and 1 Guest are viewing this topic.

Emot

  • Newbie
  • *
  • Posts: 3
    • View Profile
Possible Memory Leak SocketSelector
« on: February 22, 2016, 09:54:07 pm »
Hello,

I'm not totally sure if this is the right place to post this but it seemd like the most relevant topic for my questions.

I've recently downloaded the Visual Leak Detector (https://vld.codeplex.com/) too hopefully help me solve some leaks that might or might not appear when making applications.

When I was solving my own misstakes there was one that I could not get rid of and it was taking place when I was using the "SocketSelector".

Below is the least code possible for main.cpp
#include <SFML\Network.hpp>
#include <vld.h>

int main()
{
        sf::SocketSelector selector;

        while (true)
        {
        }

        return 0;
}
 

When I close the application I get the output:
'Network.exe' (Win32): Loaded 'E:\Projekt\Network\Debug\Network.exe'. Symbols loaded.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ws2_32.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nsi.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded.
'Network.exe' (Win32): Loaded 'C:\Program Files (x86)\Visual Leak Detector\bin\Win32\vld_x86.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Program Files (x86)\Visual Leak Detector\bin\Win32\dbghelp.dll'. Cannot find or open the PDB file.
'Network.exe' (Win32): Loaded 'C:\Windows\SysWOW64\api-ms-win-core-synch-l1-2-0.dll'. Cannot find or open the PDB file.
Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini
Visual Leak Detector Version 2.5 installed.
The thread 0x19d0 has exited with code -1073741510 (0xc000013a).
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x004444B8: 528 bytes ----------
  Leak Hash: 0x02472228, Count: 1, Total 528 bytes
  Call Stack (TID 6608):
    MSVCR110D.dll!operator new()
    Network.exe!sf::SocketSelector::SocketSelector() + 0x21 bytes
    e:\projekt\network\main.cpp (8): Network.exe!main()
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (536): Network.exe!__tmainCRTStartup() + 0x19 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (377): Network.exe!mainCRTStartup()
    kernel32.dll!BaseThreadInitThunk() + 0x12 bytes
    ntdll.dll!RtlInitializeExceptionChain() + 0x63 bytes
    ntdll.dll!RtlInitializeExceptionChain() + 0x36 bytes
  Data:
    00 00 00 00    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........
    CD CD CD CD    CD CD CD CD    CD CD CD CD    CD CD CD CD     ........ ........


Visual Leak Detector detected 1 memory leak (564 bytes).
Largest number used: 564 bytes.
Total allocations: 564 bytes.
Visual Leak Detector is now exiting.
The program '[8560] Network.exe' has exited with code -1073741510 (0xc000013a).

 

I'm using SFML 2.3.2 (Was the same with 2.1) on Windows 7, 32-bit.

I also tested the example in the documentation for the SocketSelector and it gave me the same output (with 2 additional ones).

1. Is this something that I should just ignore?
2. Is there something wrong with the SocketSelector?
3. Am I doing something wrong?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Possible Memory Leak SocketSelector
« Reply #1 on: February 22, 2016, 11:57:12 pm »
How do you close the application?

Is vld.h part of the Visual Leak Detector?
Try including it before SFML/Network.hpp
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Satus

  • Guest
Re: Possible Memory Leak SocketSelector
« Reply #2 on: February 23, 2016, 11:01:23 am »
Quote
Try including it before SFML/Network.hpp

As far as I remember, it doesn't matter where you include vld.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Possible Memory Leak SocketSelector
« Reply #3 on: February 23, 2016, 11:40:55 am »
"As far as I remember" is not good enough. Either you know and can quote sources or there's no real reason to point that out. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Emot

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Possible Memory Leak SocketSelector
« Reply #4 on: February 23, 2016, 11:45:18 am »
How do you close the application?

I'm closing it with the "Close - X" button. I've also tried with "Stop Debugging" and that gives me no error (Do you know the difference between them?). Is there a right or wrong way?

Is vld.h part of the Visual Leak Detector?

This is the file which you have to include in order for it to work.

Try including it before SFML/Network.hpp

I tried it and it was the same output.



If I remove the while-loop the application gets executed with no leak detection, which leads me to think that if I run the application with the while-loop and close the application the program never finishes and therefore never removes the SocketSelector variable. Might this be a correct assumption? If so how should I handle the closing of the application?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Possible Memory Leak SocketSelector
« Reply #5 on: February 23, 2016, 12:08:40 pm »
I only now realized that you do an infinite loop. So yes, if you close the console window you basically force cloae the application and the destructor of the selector might never get called.
Infinite loops without proper break out mechanic shouldn't be created anyways. ;)
If you just write a console application you could use C++ std::signal handling and subscribe to SIGINT or even SIGTERM allowing to break out of the loop.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Emot

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Possible Memory Leak SocketSelector
« Reply #6 on: February 23, 2016, 02:35:58 pm »
Well that solves the problem then.

Thanks for the help.  :)

 

anything