CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: memory leak in my memset usage?

    Quote Originally Posted by lab1 View Post
    Code:
    #include <winsohck2.h>
    #pragma comment(lib,"ws2_32.lib")
    
    int main()
    {
    	WSADATA wsaData = {0};
    	WSAStartup(MAKEWORD(2, 2), &wsaData);
    	int _socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); 
    	closesocket(_socket);
    	WSACleanup();
    }
    There is no memory leaks in this code.
    The "scan the heap for memory leaks" doesn't matter until the main() returns.
    Last edited by VictorN; February 20th, 2009 at 03:40 PM.
    Victor Nijegorodov

  2. #17
    Join Date
    Apr 2001
    Posts
    1,029

    Re: memory leak in my memset usage?

    There is either a memory leak in this code, or the Glowcode profiler is wrong. I dont understand how you can sit there and say there is no memory leak unless you run a profiler on it yourself.

    Have you done that?

    Many other people on google have had similiar problems with the winsock socket() call. Do a search.

    Regards

  3. #18
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: memory leak in my memset usage?

    Quote Originally Posted by lab1 View Post
    There is either a memory leak in this code, or the Glowcode profiler is wrong. I dont understand how you can sit there and say there is no memory leak unless you run a profiler on it yourself.

    Have you done that?

    Many other people on google have had similiar problems with the winsock socket() call. Do a search.

    Regards
    Even if you're right, you're saying the problem is with the socket call and not your code. So what are you looking for here?

  4. #19
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: memory leak in my memset usage?

    Quote Originally Posted by GCDEF
    Even if you're right, you're saying the problem is with the socket call and not your code. So what are you looking for here?
    Precisely. In my opinion, if you feel that you have found a memory leak in the implementation of socket(), then take the issue to the maintainer. Maybe it turns out that there really is such a bug, or maybe there is a bug in the memory leak detector.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  5. #20
    Join Date
    Nov 2003
    Posts
    1,405

    Re: memory leak in my memset usage?

    Quote Originally Posted by lab1 View Post
    I am using the lastest version of GlowCode 6.2. It says that there is a block of memory leaked when running my code as you see above. The leak is attributed to the socket() call.
    Well, if some piece of code leaks memory it's a bug and you should contact the provider.

    In this case it may be that the first call to socket allocates some global data which is then reused in further calls. You could repeatedly open/close the socket to check that possibility. Do it a 10.000 times or so while inspecting the memory allocation behaviour.

  6. #21
    Join Date
    Apr 1999
    Posts
    27,449

    Re: memory leak in my memset usage?

    Quote Originally Posted by lab1 View Post
    There is either a memory leak in this code, or the Glowcode profiler is wrong.
    Many compilers provide source code to their runtime functions. Why not confirm it by debugging the source code to see if there really is a leak?

    Anytime a programmer suspects a runtime function is faulty, and the programmer has the source code, do not say "bug" or "memory leak" without confirmation. You need to verify your claims by getting your hands dirty and seeing what's going on under the hood. Then you have solid information to give the provider (line of the source code, what goes on, etc.). GlowCode is not confirmation, as many of these third-party leak detectors have false positive reports.

    If you can't verify it yourself, then you report it to the provider and say you suspect there is a problem, and not out and out say there is a memory leak or bug, as you have no real confirmation of that.

    Regards,

    Paul McKenzie

  7. #22
    Join Date
    Apr 2001
    Posts
    1,029

    Re: memory leak in my memset usage?

    Thanks all!! Working on this now!

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured