problem
There are a lot of inherently bad things happening underneath it all.
First of all, you need to understand why OSX gets into these "laggy" situations in the first place. One is the move to LLVM, where the compiler is not optimized for performance, but for supporting multiple languages. It has virtual machine written even inside its name! It is a byproduct of competition with .NET, which was a competitor with Java. These technologies are BAD for performance. They force slow as hell garbage collection and automatic reference counting on programmers to save programmer noobs from leaking memory. To do that you just create object without worrying about when to release them (free up the memory used by objects). The garbage collector runs when you eventually take up all the main memory. What it does is GO THROUGH EVERY memory and release those that are not held by any active programs. It is a slow process, and it takes a lot of CPU time. No AAA games can survive it, so no AAA games will use JAVA, or .NET languages (like C#). Automatic reference counting is supposed to be a faster variation of garbage collection, but it is the SAME THING. The compiler will insert code "thinking" it is the right time to create and release memory. To be safe, it will only release usually when the program exits.
That is what most Java programs do anyways, grab all the memory, and don't run garbage collector until you have used up all virtual memory. It never runs. When it does the game crawls, people notice the bad performance of Java, so the garbage collector essentially does nothing until ALL memory is used up.
Now that you have reached here. How does this relate to Mountain Lion? OSX uses Objective-C, which has object oriented stuff patched onto regular C. Instead of using C++ which uses method calls, Objective-C uses message passing. SLOW! It needs to parse the message to find out what object to call. Whereas C++ just has pointers to the actual object, no parsing. And the biggest bummer? Garbage collection is default on Objective-C. You don't allocate objects, you just eat up all the memory and the garbage collector runs (the same Java, .NET, etc technology that is bad for performance). In order to save themselves Apple tries to get away from garbage collectors, by using ARC (AutomaticReferenceCounting) in Mountain Lion, and garbage collectors are deprecated. (In Lion, Garbage Collectors are not deprecated). The situation gets bad here. Now that garbage collectors are not default, the model has changed. Programmers now need to explicitly tell the OS when it is ok to release memory in ARC, or Mountain Lion will assume they want to keep using memory. If you don't program your program telling OSX that it is ok to be released, it is NOT going to be released. So all programs that were programmed from Lion and earlier ((using ARC only) )will keep leaking memory in Mountain Lion. Because they don't even have code to tell Mountain Lion it is ok to free memory. BINGO! Why is the disk swapping so much? Why am I out of memory?
Now this is not the main problem. The main problem is that garbage collection and ARC is still supported, and the fact the OSX still uses Objective-C, which is stuck with such slow technology from a by-gone era. Message passing is too slow. Garbage collection is slow. ARC is slow. Only C++ and C with manual allocation and release is fast. Do you know why garbage collection is not supported in iOS? Yep, bad for mobile battery life with CPU draining all the juice and low main memory. Instead of fixing the problem (bad technology), they are trying to patch the technology. The move to garbage collectors to ARC, is moving more of the responsibility to programmers on memory management, back to the original way programmers did it in the first place (manual management using C/C++). But the problems is that Objective-C is stuck with this ARC that is supposed to be an improvement, but is still not as fast and good to memory management as plain programmer created/released memory. The only way is to go to the lower level and use C/C++ where you can actually touch the memory and malloc/release the memory yourselves. Since llvm is supposed to support c and c++, they still have hope if you start moving chunks of the operating system to c/c++, and remove all the objective-c code that relies on ARC or garbage collection, which is keeps around a virtual machine handling the memory management.
.NET and these interpreted technology is so bad for business that XNA is being dumped and Windows Phone 8 no longer requires it. You can now do C++ directly on top of Direct3D, instead of that SLOW .NET C# layer that destroyed their third party gaming business on XBOX360. Yes it is that bad. Apple will try to cover it up, but eventually, the technology will show itself in ugly places. All these complaints on performance are a byproduct of bandaid fixes.
There are a lot of inherently bad things happening underneath it all.
First of all, you need to understand why OSX gets into these "laggy" situations in the first place. One is the move to LLVM, where the compiler is not optimized for performance, but for supporting multiple languages. It has virtual machine written even inside its name! It is a byproduct of competition with .NET, which was a competitor with Java. These technologies are BAD for performance. They force slow as hell garbage collection and automatic reference counting on programmers to save programmer noobs from leaking memory. To do that you just create object without worrying about when to release them (free up the memory used by objects). The garbage collector runs when you eventually take up all the main memory. What it does is GO THROUGH EVERY memory and release those that are not held by any active programs. It is a slow process, and it takes a lot of CPU time. No AAA games can survive it, so no AAA games will use JAVA, or .NET languages (like C#). Automatic reference counting is supposed to be a faster variation of garbage collection, but it is the SAME THING. The compiler will insert code "thinking" it is the right time to create and release memory. To be safe, it will only release usually when the program exits.
That is what most Java programs do anyways, grab all the memory, and don't run garbage collector until you have used up all virtual memory. It never runs. When it does the game crawls, people notice the bad performance of Java, so the garbage collector essentially does nothing until ALL memory is used up.
Now that you have reached here. How does this relate to Mountain Lion? OSX uses Objective-C, which has object oriented stuff patched onto regular C. Instead of using C++ which uses method calls, Objective-C uses message passing. SLOW! It needs to parse the message to find out what object to call. Whereas C++ just has pointers to the actual object, no parsing. And the biggest bummer? Garbage collection is default on Objective-C. You don't allocate objects, you just eat up all the memory and the garbage collector runs (the same Java, .NET, etc technology that is bad for performance). In order to save themselves Apple tries to get away from garbage collectors, by using ARC (AutomaticReferenceCounting) in Mountain Lion, and garbage collectors are deprecated. (In Lion, Garbage Collectors are not deprecated). The situation gets bad here. Now that garbage collectors are not default, the model has changed. Programmers now need to explicitly tell the OS when it is ok to release memory in ARC, or Mountain Lion will assume they want to keep using memory. If you don't program your program telling OSX that it is ok to be released, it is NOT going to be released. So all programs that were programmed from Lion and earlier ((using ARC only) )will keep leaking memory in Mountain Lion. Because they don't even have code to tell Mountain Lion it is ok to free memory. BINGO! Why is the disk swapping so much? Why am I out of memory?
Now this is not the main problem. The main problem is that garbage collection and ARC is still supported, and the fact the OSX still uses Objective-C, which is stuck with such slow technology from a by-gone era. Message passing is too slow. Garbage collection is slow. ARC is slow. Only C++ and C with manual allocation and release is fast. Do you know why garbage collection is not supported in iOS? Yep, bad for mobile battery life with CPU draining all the juice and low main memory. Instead of fixing the problem (bad technology), they are trying to patch the technology. The move to garbage collectors to ARC, is moving more of the responsibility to programmers on memory management, back to the original way programmers did it in the first place (manual management using C/C++). But the problems is that Objective-C is stuck with this ARC that is supposed to be an improvement, but is still not as fast and good to memory management as plain programmer created/released memory. The only way is to go to the lower level and use C/C++ where you can actually touch the memory and malloc/release the memory yourselves. Since llvm is supposed to support c and c++, they still have hope if you start moving chunks of the operating system to c/c++, and remove all the objective-c code that relies on ARC or garbage collection, which is keeps around a virtual machine handling the memory management.
.NET and these interpreted technology is so bad for business that XNA is being dumped and Windows Phone 8 no longer requires it. You can now do C++ directly on top of Direct3D, instead of that SLOW .NET C# layer that destroyed their third party gaming business on XBOX360. Yes it is that bad. Apple will try to cover it up, but eventually, the technology will show itself in ugly places. All these complaints on performance are a byproduct of bandaid fixes.
Last edited: