Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.programmer > #5079
| From | Arved Sandstrom <asandstrom3minus1@eastlink.ca> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Managed-Code Bloat |
| References | <isht62$t08$1@lust.ihug.co.nz> <isis49$cpq$1@dont-email.me> <isjjl5$sm1$1@lust.ihug.co.nz> <%5nHp.987$SG4.99@newsfe03.iad> <ismbqb$7ao$1@news.albasani.net> |
| Message-ID | <9PyHp.2843$lW4.1718@newsfe07.iad> (permalink) |
| Organization | Public Usenet Newsgroup Access |
| Date | 2011-06-07 20:50 -0300 |
On 11-06-07 08:18 PM, BGB wrote: > On 6/7/2011 3:31 AM, Arved Sandstrom wrote: >> On 11-06-06 07:17 PM, Lawrence D'Oliveiro wrote: >>> In message<isis49$cpq$1@dont-email.me>, Joshua Cranmer wrote: >>> >>>> From a programming language design concept, one thing is abundantly >>>> clear: manually-managed memory is a failure. >>> >>> And yet managed code has failed to take off in the mass market. Why >>> is that? >> >> Dude, what do you consider to be managed code? It's not just .NET and >> Java. Fact is, any language system that takes care of some details for >> you that you need to deal with yourself in C or assembly has aspects of >> management. This is a continuous spectrum, not an all or nothing. >> >> As Spolsky puts it, if your language lets you concatenate strings and >> not worry about how it happens, you've got managed code. >> >>>> Most programmers--even the very best--have very little ability to >>>> prevent >>>> memory from being leaked. That's why pretty much everyone accuses every >>>> very large application written in native languages as acting like a >>>> leaky >>>> bucket: Windows, Firefox, etc. >>> >>> And yet it is the “managed” apps that tend to be the memory hogs. >> >> Really? So C and C++ programs have never been accused of having memory >> management issues. Interesting. >> >> There is actually some truth to your observation however. Again, not for >> the reasons you think. Since when you said "managed" you really meant >> Java and .NET, I'll confine my remarks to those also. Anyway, Java and >> C#, among others, can be abused by incompetent or unschooled or ignorant >> programmers just like any other language can. If a programmer is shabby >> at programming, and more specifically, shabby at OOP, they'll write crap >> in C++ *and* Java *and* C#. With a C++ app it'll probably crash within >> minutes and very possibly never ship. With Java and C# a mediocre coder >> is much more likely to be able to release his poor code - humans being >> humans, such a coder will blame the language for bloat and slowness and >> errors. >> >> If you run across a Java app that's a memory hog, why do you think it's >> the fault of the language? It never occurred to you that it might be the >> programmers? It's not like more than 25% (being charitable) of all >> programmers working today should even be let near a keyboard, after all. >> > > well, I think it actually partly goes both ways. > > while many programmers do suck... both Java and C# implement things in > many cases, in ways which are fairly costly... > > > for example, in C, a string is just a glob of 8-bit characters in > memory, and so doesn't really take much more memory than the space to > store these characters. > > in Java, a "String" is a class instance containing an array of 16-bit > characters... > > just at the outset, this is a good deal more expensive (I calculated for > my own technology, reaching an approx 7x difference for the memory cost > of storing the string "Hello"). granted, the JVM may have a lower base > overhead, and it will drop and approach 2x as the string gets longer (a > lot of the overhead was mostly related to the cost of the object > instance and array headers). > > but, even 2x is still a significant space overhead... (due to UTF-16 vs > UTF-8...). > > also, there are many places internally where "new" will be used in > copious amounts due to the basic design of the VM architecture, ... > > a lot of this is still likely not exactly free either, and a lot of this > may add up... > > or such... > No argument from me, but in over a decade of working with Java I've yet to see a "memory hog" bloated application that couldn't have been improved to make it acceptable. Which means it could have been written that way to start with. Good design helps a great deal - minimize coupling and you minimize the number of references that are held, keeping other objects around. Cut down on object lifetimes by creating them when definitely needed, and make sure they are cut loose as soon as possible after their usefulness is done. Re-use immutable value objects when possible (flyweight), or singletons - try to recycle. Use the right data structures. Use pools. Understand GC and the Reference API. Etc etc etc. Jack Shirazi's "Java Performance Tuning" book came out in 2000, and it ought to have been a must read for every Java programmer from the gitgo. I wonder what percentage of Java programmers ever read it. A lot of it still holds true; there's plenty other updated material to cover newer Java. AHS
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-06 18:47 +1200
Re: Managed-Code Bloat Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-06 06:40 -0300
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-06 23:04 +1200
Re: Managed-Code Bloat Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-06 17:41 -0300
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 11:13 +1200
Re: Managed-Code Bloat Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-07 07:08 -0300
Re: Managed-Code Bloat Silvio <silvio@moc.com> - 2011-06-07 09:40 +0200
Re: Managed-Code Bloat Patricia Shanahan <pats@acm.org> - 2011-06-07 06:08 -0700
Re: Managed-Code Bloat Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-06 11:35 -0400
Re: Managed-Code Bloat Alessio Stalla <alessiostalla@gmail.com> - 2011-06-06 10:47 -0700
Re: Managed-Code Bloat Martin Gregorie <martin@address-in-sig.invalid> - 2011-06-06 18:21 +0000
Re: Managed-Code Bloat Michael Wojcik <mwojcik@newsguy.com> - 2011-06-08 11:48 -0400
Re: Managed-Code Bloat Martin Gregorie <martin@address-in-sig.invalid> - 2011-06-08 18:06 +0000
Re: Managed-Code Bloat Michael Wojcik <mwojcik@newsguy.com> - 2011-06-11 14:00 -0400
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 10:18 +1200
Re: Managed-Code Bloat Michael Wojcik <mwojcik@newsguy.com> - 2011-06-08 11:59 -0400
Re: Managed-Code Bloat Michael Wojcik <mwojcik@newsguy.com> - 2011-06-08 11:22 -0400
Re: Managed-Code Bloat rossum <rossum48@coldmail.com> - 2011-06-08 21:45 +0100
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 10:17 +1200
Re: Managed-Code Bloat Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-06 16:37 -0700
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 12:06 +1200
Re: Managed-Code Bloat Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-06 17:44 -0700
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 13:38 +1200
Re: Managed-Code Bloat Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-06 20:13 -0700
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 15:41 +1200
Re: Managed-Code Bloat Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-06 20:47 -0700
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-07 01:06 -0700
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 23:53 +1200
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-07 16:04 -0700
Re: Managed-Code Bloat Michael Wojcik <mwojcik@newsguy.com> - 2011-06-08 13:04 -0400
Re: Managed-Code Bloat Michal Kleczek <kleku75@gmail.com> - 2011-06-08 09:23 +0200
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-08 03:54 -0700
Re: Managed-Code Bloat bugbear <bugbear@trim_papermule.co.uk_trim> - 2011-06-07 10:10 +0100
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-07 00:37 -0700
Re: Managed-Code Bloat Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-07 07:31 -0300
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-07 16:18 -0700
Re: Managed-Code Bloat Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-07 20:50 -0300
Re: Managed-Code Bloat Gene Wirchenko <genew@ocis.net> - 2011-06-08 07:53 -0700
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-08 11:23 -0700
Re: Managed-Code Bloat BGB <cr88192@hotmail.com> - 2011-06-06 16:54 -0700
Re: Managed-Code Bloat Roedy Green <see_website@mindprod.com.invalid> - 2011-06-06 19:24 -0700
Re: Managed-Code Bloat Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-06-07 15:44 +1200
csiph-web