Does C++ finally have enough features to make memory leaks a ... memory?
-
When I read you message I have a feeling that you have no idea what is the causes of memory leak in C#.... For one thing it has little to do with "object lifecyle" FYI, unless you do interop, which is less and less common those days, the only reason for leak in C# is if your referenced by static variable or (though is the same thing in disguise) static event. Or maybe too many live threads which don't die (and all the memory they collect), could typically come from wait handle hanging forever...
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
Super Lloyd wrote:
For one thing it has little to do with "object lifecyle"
Perhaps we have a different definition of that term. I have seen problems in both Java and C# where the developers failed to properly account for how an object 'ended'. They had no problem with when the object 'started' but they never considered how to specifically control how it 'ended'. Matter of fact I suspect that I have seen code that might have that sort of problem just in the past week.
Super Lloyd wrote:
FYI, unless you do interop, which is less and less common those days, the only reason for leak in C# is if your referenced by static variable or (though is the same thing in disguise) static event. Or maybe too many live threads which don't die (and all the memory they collect), could typically come from wait handle hanging forever...
Probably been at least 15 years since I worked in a system where at least some threads did not die. Often quite a few of them. At least in Java the server frameworks build that in extensively. Most problems I have seen have been because the developers did not even seem to be aware that they were working in a threaded environment. Java and C# both have complex thread pool support and the concept has existed since before C# existed. Might have existed before Java but I wasn't introduced to it until after I first used Java. For context I started with Java 1.1.4 (well before 1.4.)
-
CodeWraith wrote:
I have also seen an entire team of Java guys sitting around a server that needed a reset every day because their opus hogged memory.
I was told by a number of unix admins that when C/C++ servers were the norm that was the standard operating procedure for any large enterprise. It was something that was planned for when putting the process together for a new server application. And it wasn't just for memory. File descriptors and sockets also needed to be cleaned up.
I think to remember for the first windows servers that this was a standard procedure (not daily, but about weekely). This not because of the applications/services but because windows was the problem at that time.
It does not solve my Problem, but it answers my question
-
:-D I should say that I had "early retired" back when auto_ptr was the new k3wl thing. I understand that after that, there have been some other features added that addressed issues that auto_ptr did not completely fix. I wonder if the state of the language is such that there are no more issues with memory leaks - which would indicate to me that no one need bother with calling delete anymore, basically making C++ like its managed cousin C#. Or am I missing something?
To be honest, I like the "feature" that I as the programmer is responsible for each and every resource and therefore need to pay attention to it. This is a clear straight forward situation and in case I'm not able to take care about the resource management then I better do not program. Vs. c#, where there are hidden traps ... I need to take care e.g. wether sometng is IDisponable or not and so on. Case by case, not straight forward. Only my 2 cents.
It does not solve my Problem, but it answers my question
-
Munchies_Matt wrote:
Of course they can be, they are the same language,
They are no longer the same language. Haven't been the same for quite some time. And actually the first ANSI C++ spec made at least one change that made it different from C.
jschell wrote:
made at least one change that made it different from C.
Which was?
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Super Lloyd wrote:
For one thing it has little to do with "object lifecyle"
Perhaps we have a different definition of that term. I have seen problems in both Java and C# where the developers failed to properly account for how an object 'ended'. They had no problem with when the object 'started' but they never considered how to specifically control how it 'ended'. Matter of fact I suspect that I have seen code that might have that sort of problem just in the past week.
Super Lloyd wrote:
FYI, unless you do interop, which is less and less common those days, the only reason for leak in C# is if your referenced by static variable or (though is the same thing in disguise) static event. Or maybe too many live threads which don't die (and all the memory they collect), could typically come from wait handle hanging forever...
Probably been at least 15 years since I worked in a system where at least some threads did not die. Often quite a few of them. At least in Java the server frameworks build that in extensively. Most problems I have seen have been because the developers did not even seem to be aware that they were working in a threaded environment. Java and C# both have complex thread pool support and the concept has existed since before C# existed. Might have existed before Java but I wasn't introduced to it until after I first used Java. For context I started with Java 1.1.4 (well before 1.4.)
ThreadPools have been around since long before java's inventor was a gleam in his grandfather's eye.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
CodeWraith wrote:
I have also seen an entire team of Java guys sitting around a server that needed a reset every day because their opus hogged memory.
I was told by a number of unix admins that when C/C++ servers were the norm that was the standard operating procedure for any large enterprise. It was something that was planned for when putting the process together for a new server application. And it wasn't just for memory. File descriptors and sockets also needed to be cleaned up.
That's SOP for any data center. Mostly because of the OS, not the applications.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Munchies_Matt wrote:
Of course they can be, they are the same language,
They are no longer the same language. Haven't been the same for quite some time. And actually the first ANSI C++ spec made at least one change that made it different from C.
In respect of the errors you can make not freeing memory they are, which was the part of the language we were discussing.
-
jschell wrote:
made at least one change that made it different from C.
Which was?
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
added plus plus to name to start with
-
:-D I should say that I had "early retired" back when auto_ptr was the new k3wl thing. I understand that after that, there have been some other features added that addressed issues that auto_ptr did not completely fix. I wonder if the state of the language is such that there are no more issues with memory leaks - which would indicate to me that no one need bother with calling delete anymore, basically making C++ like its managed cousin C#. Or am I missing something?
-
added plus plus to name to start with
ha ha not
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
jschell wrote:
made at least one change that made it different from C.
Which was?
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun