Quote from nitro:
If I understand correctly, TWS is written is Java, which is a managed (garbage collected) language.
Although it is still possible that TWS is not freeing resources correctly, this sort of problem doesn't rear it's head that often as memory leaks do/did in C/C++ (though not C# !)
nitro
True nitro, but a point of note. There are system memory leaks in Java linked to bugs in the VM. If you hit one of those in your code without realizing it, you can cause good old fashion C++ style mem leaks...they were more common in earlier versions of Java but still exist now in small numbers. See
http://developer.java.sun.com/developer/bugParade/bugs/4724129.html for a hysterical and current one.
Also, the VM maintains a pool of memory for the app to use. As the app needs more, the VM increases the size of the pool...but the VM never releases memory from the pool in case the app needs it again, even if the garbage collector "frees" it. That's why when you look at javaw.exe under the task manager in windows it's got a huge RAM footprint...most of that is probably empty, reserved space from a previous memory high. If the VM can't acquire more memory for it's pool from the OS, and the garbage collector either can't keep up or can't free anythign else, you can get OutOfMemory errors. So, interestingly, if you have a multithreaded app that allocates alot of memory with each iteration, and that consistently pre-empts the garbage collector, the VM might have to keep grabbing memory from the OS before it can free it...the heap (pool) is expanding. And then with some systems, like Win98 with its poor virtual memory setup, the OS might run out of memory to grab (because your C drive, where Win98 keeps its virtual memory, is full or something and your system doesn't have enough physical memory). And then blam, java crashes along with probably everything else on your system.
Got to watch out for those threads...
So, you can pretty easily create memory errors in Java, just that they are tend to be different types of memory errors than you'd see in a C++ app.
Java rules and garbage collection leads to better code but having such a huge memory footprint when an app has been running for awhile is a pretty significant drawback. The newer Hotspot VMs and the like are sooooo much better, but as a java developer, you have to be aware that you are not absolved from all memory considerations.
