Re: RAM usage

2024-04-11 Thread Neil C Smith
On Thu, 11 Apr 2024 at 09:39, Jens Zurawski  wrote:
>  A class static member is never freed, once the
> class is loaded.

A pedantic nitpick! :-)

A class static member can be freed, when the classloader is eligible
for GC.  In the context of NetBeans modules, OSGi, etc. then that
could be relevant.

Best wishes,

Neil

-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: RAM usage

2024-04-11 Thread Jens Zurawski
Others already have written good points to this question. I just want to 
add my 2 cents.


Netbeans is doing a lot of stuff in the background and it's using a 
significant amount of RAM for speeding things up. A professor of mine 
once said something like "If you have a lot of RAM and you don't use it 
to do useful things, why did you have bought it in the first place?". 
What he wanted to say was: of course no one should waste RAM to do 
senseless things or because he just has forgotten to free it up again 
and the like. But, if you can do useful things with it, e.g. to speed 
things up significantly, then do it! ;-) Especially these days, when RAM 
is cheap.


On the other hand, some Java applications are indeed wasting RAM, 
because of mistakes done by the developers. Back in my days, when I 
started to learn Java during my studies, people were saying "Java is 
nice. You don't have to take care about freeing memory any more because 
the garbage collector is doing it for you".  Although this statement is 
not exactly false, it led to a careless handling of memory by some 
developers. Because of the garbage collection it is very important to 
place the variables and objects in the right scope. A globally scoped 
object is never freed. A class static member is never freed, once the 
class is loaded. A class member is freed together with its object 
instance. An object instance is freed after the instance is not 
referenced by any other instance any more. Especially the last thing is 
a pitfall for some developers. This means for example: sometimes there 
is just this "small little object" in the session scope or global scope. 
But the developer has forgotten (or never knew it, because this class 
was written by a different developer) that this small object (even if 
only some bytes in size) may have one single reference to another 
object, let's say a Collection with thousands or millions of entries in 
it. Then this small global object of 50 bytes is the cause that the 
big Collection (with maybe even more big references and so maybe up to 
MBs or even GBs) behind it will never be freed by the garbage collection.


This is basic knowledge a Java programmer has to have in mind, I know. 
But even experienced developers sometimes fall into this because 
especially in big projects it is easy to oversee a small little 
reference to a hidden big object, or to misinterpret the lifetime of one 
instance... "oh I didn't know this instance is although referenced by 
this long running thread although the thread is only needing it to start 
up, etc. pp.".


cu
Jens



Am 10.04.2024 um 11:31 schrieb Tom:

Why does Java and Netbeans use extreme amounts of RAM for simple apps?
Can there be done something about it?

-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists




-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: RAM usage

2024-04-10 Thread Thomas Wolf
I've been writing Java applications since around 1995 and I have written many 
sizable ones that didn't require a huge amount of RAM.  Of course the JVM 
itself is a fixed overhead which is now, what, 50MB? (but even that can be 
ameliorated via modularization these days), and more and more third-party 
libraries and frameworks are in use, all of which add to an application's 
footprint.  And then there's the skill of the developer, lack of emphasis on 
design and testing, etc.  When applications had a life span of years or even 
decades, the cost of design, testing, performance tuning, etc. was worth it.  
Nowadays, there's much more of an emphasis of speed-to-market and the resulting 
software quality and performance reflects that.  But that's a general 
observation that doesn't just hold for Java applications - today's web apps in 
whatever language they're written are pretty slow and humongous in their RAM 
requirements.  But folks don't often complain about their Google Chrome or 
Safari browsers reaching giga-bytes in size?!

Back in the late 90's, when Netbeans first came out, it was a *lot* smaller.  
But back then, life was simple.  There was no groovy, maven, ivy, built-in web 
servers, support for web apps and frameworks, other programming languages, 
terminals, to-do lists, different IDE look & feels,...the list is endless - and 
it all adds up.

Also, Java app processes reserve memory via various JVM arguments (-Xms, -Xmx, 
etc.)  I don't know what Netbeans sets those parameters to these days, but you 
can adjust them yourself in the netbeans.conf file.  And Netbeans may not 
actually be using as much memory as you see the process take up - but once a 
Java process claims operating system memory (e.g. it needed a lot of RAM for a 
particular, but temporary operation), it doesn't give it back (at least that's 
how it used to be).

In sum, I think blaming Java for Java applications' large memory consumption is 
misguided.  If you could write the sort of applications written in Java in 
other languages (and it's not at all clear you could, given the huge Java 
ecosystem of ready-made third-party components/functionality), and in the time 
allowed to write those applications, they'd probably use just as much RAM.  
(yes, I do understand that what I just wrote may not hold in specific 
application domains, but I'm making a cross-domain point).

Just my $.02.
Tom



> On Apr 10, 2024, at 12:18 PM, Raul Cosio  wrote:
> 
> That's the question I've asked myself for years... In the first versions of 
> Java that was a concern: Why did Netbeans use 200MB of RAM when Visual Basic 
> used just 10MB or less? PC's were more limited in RAM, maybe that's why Java 
> was not popular in desktop apps, but succeeded with web servers, where you 
> could afford a server with more RAM and disk drive. We had a joke at the 
> office: "Java was slow and used huge amounts of RAM, however, now PC's have 
> faster processors and lots of RAM!" :)
> These days it is not uncommon to see Netbeans using 1.5GB of RAM, yes it uses 
> caches, precompiling, error detection, popup documentation and many more 
> features but it still does not make sense.
> I don't know if somebody has an answer to this question but I guess it is 
> related to performance and GC: If you have a considerable amount of RAM 
> reserved, it's much faster to allocate new objects. Java is very efficient at 
> Object allocation, in the same way, garbage collection is so fast that you 
> don't even notice when it is running, so I would say: Java uses lots of RAM 
> because performance is more important.
> Finally, I remember many years ago when a coworker went to a JBoss training 
> course, and he asked the instructor: Why do Java and JBoss have to use such 
> amounts of RAM? The instructor made a small pause and then he said 
> (rephrasing at today's economy): How much is a developer salary? 20-30 
> dollars an hour? And, how much is a 16 GB stick of RAM? 16 dollars? Well, 
> just buy more RAM for your developers and let them focus on solving business 
> problems...
> 
> 
> On Wed, Apr 10, 2024 at 3:32 AM Tom  > wrote:
>> Why does Java and Netbeans use extreme amounts of RAM for simple apps?
>> Can there be done something about it?
>> 
>> -
>> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org 
>> 
>> For additional commands, e-mail: users-h...@netbeans.apache.org 
>> 
>> 
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>> 



Re: RAM usage

2024-04-10 Thread Raul Cosio
That's the question I've asked myself for years... In the first versions of
Java that was a concern: Why did Netbeans use 200MB of RAM when Visual
Basic used just 10MB or less? PC's were more limited in RAM, maybe that's
why Java was not popular in desktop apps, but succeeded with web
servers, where you could afford a server with more RAM and disk drive. We
had a joke at the office: "Java was slow and used huge amounts of RAM,
however, now PC's have faster processors and lots of RAM!" :)
These days it is not uncommon to see Netbeans using 1.5GB of RAM, yes it
uses caches, precompiling, error detection, popup documentation and many
more features but it still does not make sense.
I don't know if somebody has an answer to this question but I guess it is
related to performance and GC: If you have a considerable amount of RAM
reserved, it's much faster to allocate new objects. Java is very efficient
at Object allocation, in the same way, garbage collection is so fast that
you don't even notice when it is running, so I would say: Java uses lots of
RAM because performance is more important.
Finally, I remember many years ago when a coworker went to a JBoss training
course, and he asked the instructor: Why do Java and JBoss have to use such
amounts of RAM? The instructor made a small pause and then he said
(rephrasing at today's economy): How much is a developer salary? 20-30
dollars an hour? And, how much is a 16 GB stick of RAM? 16 dollars? Well,
just buy more RAM for your developers and let them focus on solving
business problems...


On Wed, Apr 10, 2024 at 3:32 AM Tom  wrote:

> Why does Java and Netbeans use extreme amounts of RAM for simple apps?
> Can there be done something about it?
>
> -
> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
> For additional commands, e-mail: users-h...@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>


Re: RAM usage

2024-04-10 Thread Alonso Del Arte
Can you give an example of this using "extreme amounts of RAM for simple
apps"? We're talking something more involved than HelloWorld, but not
quite  toy-examples/src/viewers/MandelbrotJuliaViewer.java at main ·
Alonso-del-Arte/toy-examples · GitHub
,
right?
That one doesn't give me any problems if I don't zoom in too far.

Al

On Wed, Apr 10, 2024 at 5:33 AM Tom  wrote:

> Why does Java and Netbeans use extreme amounts of RAM for simple apps?
> Can there be done something about it?
>
> -
> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
> For additional commands, e-mail: users-h...@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
>


RAM usage

2024-04-10 Thread Tom
Why does Java and Netbeans use extreme amounts of RAM for simple apps?
Can there be done something about it?

-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists