Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java daemon

Reply
Thread Tools

Java daemon

 
 
SL
Guest
Posts: n/a
 
      11-13-2012
sl@exabyte wrote:

> Acutally I mean the my c/c++ programming in Linux would probably take
> too long a time to meet my target since I have done anything on Linux.
> My server program has to process XML string and MySQL. I had a look
> at a sample C program with MySQL API last night, it did not look that
> intimidating. At this stage I am a bit encouraged to dip my little
> toe into the Linux pool. But my programming experience tells me there
> are always surprises.


A correction, the statement "...since I have done anything on Linux" should
read "...since I have not done anything on Linux".


 
Reply With Quote
 
 
 
 
SL
Guest
Posts: n/a
 
      11-13-2012
David Lamb wrote:
> On 12/11/2012 9:17 AM, sl@exabyte wrote:
>> Since java also adopts the garbage collector mechanism, would java
>> daemon suffers from the same memory problem ?

>
> There are several different ways to do garbage collection, so flaws in
> one implementation have no bearing on what goes on with another.
>
> The most common complaint that crosses implementations is the
> unpredictability of when a gc happens, which can be a problem for a
> program with serious real-time constraints. IIRC Java implementations
> often have the gc run continuously and incrementally in a separate
> thread, which evens out the effect.


I did some google'ing on garbage collector (GC) in java and found that it is
a big and complicated topic.
Java programmer has no permission to invoke it directly, beside juggling its
settings to adjust its frequency of running and the type of collector to
run. Even then how the GC is invoked stilll lies beyond programmer's
control.

It gets me thinking.

Why bother with it (people in the finance trade especially) ? Are the
advantages so great over c/c++ ? If the answer is yes, I can only think that
the reason is portability. Otherwise forget about tweaking GC; go for C/C++;
programmer has full control over memory management, and it is faster than
java.

I hope my opinion does not ignite the ire of java people.

I do have a question on GC: how to run the GC continuously ? Create a
thread, do some memory juggling to induce the GC to run ?




 
Reply With Quote
 
 
 
 
SL
Guest
Posts: n/a
 
      11-13-2012
Peter Duniho wrote:
>
> Probably not. Most of the "Java people" are secure enough in their
> knowledge that they are using the right tool for the job to not worry
> about what some person grinding an anti-Java axe might have to say.
>....
>


I have no axe to grind, Peter.

I have hardly programmed beyond "Helo World" in java. The above was just my
personal opinion, it could be very well wrong.

I am just hoping to learn some more esoteric facts about about java and
c/c++, which only people with a lot of experiece can give.

I remember what my former once said:

"Read about people's biograhy. They take a life time to attain their
achievements, and the reader takes 1 to 2 weeks to learn them. I don't think
there is a better deal."


 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      11-13-2012
On 11/13/2012 02:40 AM, SL wrote:
> David Lamb wrote:
>> On 12/11/2012 9:17 AM, sl@exabyte wrote:
>>> Since java also adopts the garbage collector mechanism, would java
>>> daemon suffers from the same memory problem ?

>>
>> There are several different ways to do garbage collection, so flaws in
>> one implementation have no bearing on what goes on with another.
>>
>> The most common complaint that crosses implementations is the
>> unpredictability of when a gc happens, which can be a problem for a
>> program with serious real-time constraints. IIRC Java implementations
>> often have the gc run continuously and incrementally in a separate
>> thread, which evens out the effect.

>
> I did some google'ing on garbage collector (GC) in java and found that it is
> a big and complicated topic.
> Java programmer has no permission to invoke it directly, beside juggling its
> settings to adjust its frequency of running and the type of collector to
> run. Even then how the GC is invoked stilll lies beyond programmer's
> control.
>
> It gets me thinking.
>
> Why bother with it (people in the finance trade especially) ? Are the
> advantages so great over c/c++ ? If the answer is yes, I can only think that
> the reason is portability. Otherwise forget about tweaking GC; go for C/C++;
> programmer has full control over memory management, and it is faster than
> java.
>
> I hope my opinion does not ignite the ire of java people.

[ SNIP ]

No ire on my part. I back up what Peter said (particularly with respect
to maintenance and reliability), and I'll add a few remarks of my own.

Think about why you'd want to invoke the Java GC yourself, and what that
would entail. You'd want to know *when* to do it - if you wrote the code
yourself to make that decision, and you were really good and really
experienced, it would probably look a lot like _existing_ code for some
GC or another. If you weren't that good then your code just wouldn't cut it.

By "code" I mean both the actual source and the GC parameters that you
can tune.

At first glance it might seem like this indirection - setting parameters
- removes a lot of control. That's not the case.

I'm not saying this is you - you already said it's not - but people who
assert that they can do better decision-making as to when to invoke a GC
run than the code that represents years of experience of GC specialists
strike me in the same vein as people who assert they can get better gas
mileage using manual stick than people who drive modern automatic
transmission cars. A very few people *can* do that - the majority (huge
majority) can't.

AHS
 
Reply With Quote
 
David Lamb
Guest
Posts: n/a
 
      11-13-2012
On 13/11/2012 1:40 AM, SL wrote:
> David Lamb wrote:
>> On 12/11/2012 9:17 AM, sl@exabyte wrote:
>>> Since java also adopts the garbage collector mechanism, would java
>>> daemon suffers from the same memory problem ?

>>
>> There are several different ways to do garbage collection, so flaws in
>> one implementation have no bearing on what goes on with another.

> Why bother with it (people in the finance trade especially) ? Are the
> advantages so great over c/c++ ? If the answer is yes, I can only think that
> the reason is portability. Otherwise forget about tweaking GC; go for C/C++;
> programmer has full control over memory management, and it is faster than
> java.


GC has several big advantages over programmer control, one of them being
how often programmers get things wrong. A bug-free GC can be written
once, by experts, tested thoroughly, then lives on not subject to bugs
introduced by thousands of programmers across the hundreds of packages
you might use in any one program.

You never get reuse of already-deallocated memory, a classic source of
segmentation faults.

You never get the most common forms of memory leak, forgetting to
deallocate and losing the last pointer to the allocated memory. Though
people can misprogram to have long-lived structures point to ones no
longer needed; dunno how common that is. Technically this does not count
as a "memory leak"; rather it's "keeping data around too long that you
can still free eventually".

A compactifying GC can also *speed up* memory allocation and *reduce*
heap footprint by reducing fragmentation.

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-13-2012
On 11/13/2012 4:36 PM, Martin Gregorie wrote:
> On Mon, 12 Nov 2012 22:06:50 -0500, Arne Vajhøj wrote:
>> On 11/12/2012 5:07 PM, Martin Gregorie wrote:
>>> On Mon, 12 Nov 2012 23:55:58 +0800, sl@exabyte wrote:
>>>> I have sort of given up hope on PHP daemon; one cannot touch its GC I
>>>> suppose. I am adamant to go C/C++; I have not done anything on Linux.
>>>>
>>> I've not done a lot with PHP, but haven't (so far) run into any
>>> particular problems with the Apache/PHP combination under Linux.

>>
>> For the typical web page the request scope is sufficient to avoid
>> problems.
>>
>> But a daemon is not a typical web page.
>>

> I've been picking it up from "Programming PHP" (O'Reilly). That doesn't
> mention anything even vaguely resembling a PHP Daemon.
>
> What is it?
> If you have Apache, why would you need it?
> Is it some sort of lightweight web server?


You know what a daemon is.

Besides the web integration with Apache and IIS that accounts
for 99+% of PHP usage, then PHP also comes with a command line
utility.

So you can write a daemon in PHP and run it via the command line
utility.

Arne


 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      11-14-2012
In article <k7sq0e$poi$(E-Mail Removed)>, "SL" <(E-Mail Removed)>
wrote:

> I do have a question on GC: how to run the GC continuously ? Create a
> thread, do some memory juggling to induce the GC to run ?


On my platform, the JVM automatically spawns several threads to
facilitate garbage collection, including one called "Concurrent
Mark-Sweep GC Thread," which runs at a moderately lower priority than
the event queue. The host's scheduler uses multiple cores (when
available) to balance the load in favor of the user. The overall effect
is that even "busy" programs remain responsive, and I rarely notice GC
unless I'm looking for it, say in a profiler.

IIUC, the exact number and names of threads is platform-dependent. You
can use jvisualvm, included with the JDK, to see a thread timeline; or
you can take a snapshot of running threads via `kill -SIGQUIT pid`.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-14-2012
On 11/14/2012 4:33 PM, Martin Gregorie wrote:
> On Tue, 13 Nov 2012 17:31:22 -0500, Arne Vajhøj wrote:
>
>> You know what a daemon is.
>>
>> Besides the web integration with Apache and IIS that accounts for 99+%
>> of PHP usage, then PHP also comes with a command line utility.
>>
>> So you can write a daemon in PHP and run it via the command line
>> utility.
>>

> Thanks for the clarification. I thought you must have been talking about
> some special PHP daemonising framework or library.


Nope. Just not very good at explaining what I meant.

Arne


 
Reply With Quote
 
Arne Vajhj
Guest
Posts: n/a
 
      11-18-2012
On 11/12/2012 4:24 PM, Jim Janney wrote:
> "sl@exabyte" <(E-Mail Removed)> writes:
>
>> I gather that PHP daemon suffers from memory leak problem due to its garbage
>> collector mechanism.
>>
>> Since java also adopts the garbage collector mechanism, would java daemon
>> suffers from the same memory problem ?

>
> Probably not: not all implementations of GC are equal, and you can't
> generalize from one to another. For what it's worth, Twitter is in the
> process of migrating from Ruby to Java due to problems with memory
> management, and claims to be happy with the results:
>
> http://www.theregister.co.uk/2012/11...saved_by_java/


The article is not very specific - "manage memory more efficiently" do
not tell much about the issues.

But other sources explain. Ruby do use mark and sweep like Java and
not ref count as PHP. But it has no generations and are global stop
during the entire GC. Which is not as good as modern Java GC's.

Arne


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-18-2012
On 11/13/2012 4:50 PM, Martin Gregorie wrote:
> On Tue, 13 Nov 2012 10:56:47 +0800, sl@exabyte wrote:
>> My server program has to process XML string and MySQL.
>>

> PHP can deal with XML and interface to MySQL, though why anybody would
> use it when using PostgreSQL has more standardised SQL and is as easy to
> install for the same price, is more than I can imagine.


More users => better support.

And most of the non-standard SQL problems went away with
MySQL 4.1 and 5.0 back in 2005 and 2006.

Arne


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing java daemon server: start and stop calvin01 Java 5 05-30-2009 05:39 PM
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Floris Bruynooghe Python 1 03-24-2009 02:58 PM
Re: PEP 3143: Standard daemon process library (was: Writing awell-behaved daemon) Jean-Paul Calderone Python 0 03-20-2009 01:02 PM
Daemon Win32::Daemon; ph1975@gmail.com Perl Misc 0 09-07-2006 10:58 AM
running java program as daemon on Unix System Fatih Java 4 04-09-2004 09:40 AM



Advertisments