Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java - memory allocation

 
Raju Parab
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Which of the following is better approach for better performance.

1. Class with lot of method (source code - 6000 line)
Or
2. Mutliple classes with few methods (100 * 60 class)

There is definitely modularity in second case, but in terms of performance is there any difference?

Is there memory allocation difference?

Raju
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35753
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raju,
It's better to have good design (option 2) than make micro-performance judgements. It is highly unlikely to matter which is faster because they will be so close.
 
Raju Parab
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am more looking for what would be JVM allocation for this example and how the performance will be affected ?

Thanks,
Raju
 
Kees Jan Koster
JavaMonitor Support
Rancher
Posts: 251
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Raju,

Dude, read Jeanne's advise.
 
Tim Holloway
Bartender
Posts: 18419
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's old advice, but true: It's easier to optimize a clean design than to clean up a prematurely-optimized design.

Almost never do the observed bottlenecks in an application occur where you "knew" they were going to be. I speak from long experience as one whose job typically requires better performance and reliability than most. Though these days, that's not saying much.

One thing I've also noticed is that the really efficient programs are actually smaller and cleaner than the "pre-optimized" versions. One of my favorite examples of that is the AmigaOS Exec (kernel). It's built on Djikstra's T.H.E. micro OS core, a doubly-linked list manager and a few other stock subsystems, yet it provided a similar level of functionality in under 4MB of RAM (originally it was more like 256K) to a similar-era Linux+X Window system in 16MB. Plus so fat, it's the only mass-distribution OS that has had true real-time functionality.

So I'd worry less about how to pack methods into classes and more about why you need all those methods to begin with.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there memory allocation difference?

Raju


Raju, you should test this yourself to find the "better" performance. Please post your findings if you do.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!