Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java daemon

Reply
Thread Tools

Java daemon

 
 
Arne Vajhj
Guest
Posts: n/a
 
      11-18-2012
On 11/13/2012 1:40 AM, SL wrote:
> I did some google'ing on garbage collector (GC) in java and found that it is
> a big and complicated topic.


It certainly is.

> 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++ ?


Yes.

GC is a lot better than manual deallocation for non realtime
usage as programmer tend to forget to deallocate resulting
in memory leaks.

And there are also other areas where the programmers end up
misusing the control that C++ provides you.

> If the answer is yes, I can only think that
> the reason is portability.


That is one reason but there are plenty of other.

> Otherwise forget about tweaking GC;


Yes. Because 99.999% of developers can not do a better job than what
the GC specialists has designed.

> go for C/C++;
> programmer has full control over memory management,


Which is a very good reason for not choosing C/C++ unless you
have special requirements like realtime, hardware interface or
kernel code.

> and it is faster than
> java.


That is not always the case.

> 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 ?


The GC should not run continuously - that would be very bad for
performance.

Arne


 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      11-18-2012
On 11/12/2012 10:40 PM, SL 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 ?



I haven't been following closely, so I don't know what version of Java
you're working with, but a web search for "java garbage collection
tuning" usually gives lots of good hits.

<http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#available_collectors>

You probably want the parallel GC or the concurrent GC. And no, you do
not create a new thread or "juggle memory," you configure it externally
to your application.

Also, take a look at the System.gc() call, but DON'T USE THAT unless
you're sure you need it. The garbage collector is probably smarter than
you are about when and how to collect unused memory, frankly.

<http://stackoverflow.com/questions/2414105/why-is-it-a-bad-practice-to-call-system-gc>



 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-19-2012
On 11/18/2012 8:05 PM, Martin Gregorie wrote:
> On Sun, 18 Nov 2012 16:43:39 -0500, Arne Vajhøj wrote:
>> And most of the non-standard SQL problems went away with MySQL 4.1 and
>> 5.0 back in 2005 and 2006.
>>

> So, you're telling me its now ditched auto-incrementing fields and has
> implemented sequences?


No.

But then auto increment is also the standard (with IDENTITY
keyword though).

And it is also the most widely supported: MySQL,
SQLServer, DB2 etc..

PostgreSQL has it in the form of SERIAL (even though it is just
syntactic sugar for a sequence).

Sequences is really an Oracle and PostgreSQL proprietary thing.

MySQL are trying to converge towards standards not away from
standards.

Arne





 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      11-19-2012
Arne Vajhj wrote:
> And most of the non-standard SQL problems went away with
> MySQL 4.1 and 5.0 back in 2005 and 2006.


TIMESTAMP remains non-standard.
http://dev.mysql.com/doc/refman/5.5/en/datetime.html
http://dev.mysql.com/doc/refman/5.5/...alization.html

I am aware of no perfectly compliant SQL DBMS.

--
Lew
 
Reply With Quote
 
Arne Vajhj
Guest
Posts: n/a
 
      11-19-2012
On 11/18/2012 11:10 PM, Lew wrote:
> Arne Vajhj wrote:
>> And most of the non-standard SQL problems went away with
>> MySQL 4.1 and 5.0 back in 2005 and 2006.

>
> TIMESTAMP remains non-standard.
> http://dev.mysql.com/doc/refman/5.5/en/datetime.html
> http://dev.mysql.com/doc/refman/5.5/...alization.html


Note that the closest to SQL TIMESTAMP is not MySQL TIMESTAMP
but MySQL DATETIME.

(the difference between standard and DATETIME is that DATETIME is
missing the fractional seconds and TZ)

> I am aware of no perfectly compliant SQL DBMS.


True.

But some stuff are worse than other.

Very old versions of MySQL was pretty bad. UNION was
added in 4.0, subqueries was added in 4.1 and views
was added in 5.0.

Arne


 
Reply With Quote
 
jlp
Guest
Posts: n/a
 
      11-19-2012
Le 18/11/2012 23:02, markspace a crit :
> On 11/12/2012 10:40 PM, SL 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 ?

>
>
> I haven't been following closely, so I don't know what version of Java
> you're working with, but a web search for "java garbage collection
> tuning" usually gives lots of good hits.
>
> <http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html#available_collectors>
>
>
> You probably want the parallel GC or the concurrent GC. And no, you do
> not create a new thread or "juggle memory," you configure it externally
> to your application.
>
> Also, take a look at the System.gc() call, but DON'T USE THAT unless
> you're sure you need it. The garbage collector is probably smarter than
> you are about when and how to collect unused memory, frankly.
>
> <http://stackoverflow.com/questions/2414105/why-is-it-a-bad-practice-to-call-system-gc>
>
>
>
>

If the OP uses a JVM Java HotSpot 7 ( Oracle or Open JDK) , he can take
a look to the G1 ( G first) garbage collector. It is an improve of the
CMS garbage collector. This garbage collector is more "Real Time" than
the others garbage collectors.

--
Cordialement
Jean-Louis Pasturel
 
Reply With Quote
 
Arved Sandstrom
Guest
Posts: n/a
 
      11-20-2012
On 11/18/2012 09:41 PM, Arne Vajhøj wrote:
> On 11/18/2012 8:05 PM, Martin Gregorie wrote:
>> On Sun, 18 Nov 2012 16:43:39 -0500, Arne Vajhøj wrote:
>>> And most of the non-standard SQL problems went away with MySQL 4.1 and
>>> 5.0 back in 2005 and 2006.
>>>

>> So, you're telling me its now ditched auto-incrementing fields and has
>> implemented sequences?

>
> No.
>
> But then auto increment is also the standard (with IDENTITY
> keyword though).
>
> And it is also the most widely supported: MySQL,
> SQLServer, DB2 etc..


Oracle has sequences, PostgreSQL has sequences, SQL Server has sequences
(now), DB2 has sequences...MySQL, I don't think so (I stand to be
corrected).

> PostgreSQL has it in the form of SERIAL (even though it is just
> syntactic sugar for a sequence).
>
> Sequences is really an Oracle and PostgreSQL proprietary thing.


Not anymore. Sequences were introduced into the SQL standard in 2003. As
you alluded to above, this version introduced identity columns (which
are considered to use an internal sequence generator).

> MySQL are trying to converge towards standards not away from
> standards.


No more so than anyone else.

> Arne


AHS

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-20-2012
On 11/19/2012 7:32 PM, Martin Gregorie wrote:
> On Sun, 18 Nov 2012 20:41:19 -0500, Arne Vajhøj wrote:
>
>> On 11/18/2012 8:05 PM, Martin Gregorie wrote:
>>> On Sun, 18 Nov 2012 16:43:39 -0500, Arne Vajhøj wrote:
>>>> And most of the non-standard SQL problems went away with MySQL 4.1 and
>>>> 5.0 back in 2005 and 2006.
>>>>
>>> So, you're telling me its now ditched auto-incrementing fields and has
>>> implemented sequences?

>>
>> No.
>>
>> But then auto increment is also the standard (with IDENTITY keyword
>> though).
>>
>> And it is also the most widely supported: MySQL,
>> SQLServer, DB2 etc..
>>
>> PostgreSQL has it in the form of SERIAL (even though it is just
>> syntactic sugar for a sequence).
>>
>> Sequences is really an Oracle and PostgreSQL proprietary thing.
>>

> I haven't looked at the SQL standard for quite a while and thought
> sequences were in it. My bad.
>
> I have to say I like sequences a lot better than auto-incrementing fields
> for one reason: you know what the unique value is before doing the
> INSERT, which seems cleaner to me that doing the INSERT and then reading
> the new row to find out what the auto-incremented value is.


You don't read the row to find out what the generated key is.

You query the connection for what it is.

The function name is database specific, but JDBC encapsulate
it nicely via Statement getGeneratedKeys.

Arne

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      11-20-2012
On 11/19/2012 7:38 PM, Arved Sandstrom wrote:
> On 11/18/2012 09:41 PM, Arne Vajhøj wrote:
>> On 11/18/2012 8:05 PM, Martin Gregorie wrote:
>>> On Sun, 18 Nov 2012 16:43:39 -0500, Arne Vajhøj wrote:
>>>> And most of the non-standard SQL problems went away with MySQL 4.1 and
>>>> 5.0 back in 2005 and 2006.
>>>>
>>> So, you're telling me its now ditched auto-incrementing fields and has
>>> implemented sequences?

>>
>> No.
>>
>> But then auto increment is also the standard (with IDENTITY
>> keyword though).
>>
>> And it is also the most widely supported: MySQL,
>> SQLServer, DB2 etc..

>
> Oracle has sequences, PostgreSQL has sequences, SQL Server has sequences
> (now),


In 2012. They have had identity auto increment since it was called
Sybase.

> DB2 has sequences...MySQL, I don't think so (I stand to be
> corrected).
>
>> PostgreSQL has it in the form of SERIAL (even though it is just
>> syntactic sugar for a sequence).
>>
>> Sequences is really an Oracle and PostgreSQL proprietary thing.

>
> Not anymore. Sequences were introduced into the SQL standard in 2003. As
> you alluded to above, this version introduced identity columns (which
> are considered to use an internal sequence generator).


????

SQL IDENTITY columns are used the same way as MySQL auto increment
not the same way as sequences in Oracle and PostgreSQL.

There must be something like a sequence behind it. But if it is not
visible and the usage is restricted to the auto increment way, then
that is implementation.

Arne

 
Reply With Quote
 
SL@maxis
Guest
Posts: n/a
 
      11-20-2012
On Tue, 20 Nov 2012 03:39:10 +0800, jlp <(E-Mail Removed)> wrote:

> If the OP uses a JVM Java HotSpot 7 ( Oracle or Open JDK) , he can take
> a look to the G1 ( G first) garbage collector. It is an improve of the
> CMS garbage collector. This garbage collector is more "Real Time" than
> the others garbage collectors.
>


I decide that I have windows c/c++ programming that I think I can get a
daemon in C to run by month-end, since my daemon deals with XML processing
and MySQL, and of course communicating over sockets.

Hope that you people are in the C/C++ Linux group, which I shall turn to
if I get stuck.

--
Using Opera's revolutionary email client: http://www.opera.com/mail/
 
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