|
-
February 20th, 2009, 03:22 PM
#16
Re: memory leak in my memset usage?
 Originally Posted by lab1
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
-
February 20th, 2009, 03:26 PM
#17
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
-
February 20th, 2009, 03:28 PM
#18
Re: memory leak in my memset usage?
 Originally Posted by lab1
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?
-
February 20th, 2009, 08:29 PM
#19
Re: memory leak in my memset usage?
 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.
-
February 21st, 2009, 01:58 AM
#20
Re: memory leak in my memset usage?
 Originally Posted by lab1
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.
-
February 21st, 2009, 03:54 AM
#21
Re: memory leak in my memset usage?
 Originally Posted by lab1
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
-
February 23rd, 2009, 07:22 AM
#22
Re: memory leak in my memset usage?
Thanks all!! Working on this now!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|