head	1.22;
access;
symbols;
locks
	nobody:1.22; strict;
comment	@# @;


1.22
date	99.09.30.18.26.55;	author nobody;	state Exp;
branches;
next	1.21;

1.21
date	99.09.30.18.24.25;	author nobody;	state Exp;
branches;
next	1.20;

1.20
date	99.09.30.18.17.40;	author nobody;	state Exp;
branches;
next	1.19;

1.19
date	99.09.30.18.12.19;	author nobody;	state Exp;
branches;
next	1.18;

1.18
date	99.09.30.18.05.35;	author nobody;	state Exp;
branches;
next	1.17;

1.17
date	99.09.30.18.03.05;	author nobody;	state Exp;
branches;
next	1.16;

1.16
date	99.09.30.17.59.03;	author nobody;	state Exp;
branches;
next	1.15;

1.15
date	99.09.30.17.57.23;	author nobody;	state Exp;
branches;
next	1.14;

1.14
date	99.09.30.17.54.12;	author nobody;	state Exp;
branches;
next	1.13;

1.13
date	99.05.07.18.11.36;	author nobody;	state Exp;
branches;
next	1.12;

1.12
date	99.05.06.23.50.09;	author nobody;	state Exp;
branches;
next	1.11;

1.11
date	99.05.06.23.49.33;	author nobody;	state Exp;
branches;
next	1.10;

1.10
date	99.04.29.19.40.14;	author nobody;	state Exp;
branches;
next	1.9;

1.9
date	99.04.24.01.16.36;	author nobody;	state Exp;
branches;
next	1.8;

1.8
date	99.04.22.07.57.34;	author nobody;	state Exp;
branches;
next	1.7;

1.7
date	99.04.21.18.29.40;	author nobody;	state Exp;
branches;
next	1.6;

1.6
date	99.04.21.18.21.40;	author nobody;	state Exp;
branches;
next	1.5;

1.5
date	99.04.21.00.56.22;	author nobody;	state Exp;
branches;
next	1.4;

1.4
date	99.04.20.15.39.55;	author nobody;	state Exp;
branches;
next	1.3;

1.3
date	99.04.20.15.38.48;	author nobody;	state Exp;
branches;
next	1.2;

1.2
date	99.04.20.15.36.59;	author nobody;	state Exp;
branches;
next	1.1;

1.1
date	99.04.20.15.36.48;	author nobody;	state Exp;
branches;
next	;


desc
@null
@


1.22
log
@null
@
text
@IDependOn-Set: 1
IDependOn-Set: 116
IDependOn-Set: 130
IDependOn-Set: 2
IDependOn-Set: 7
IDependOn-Set: 98
LastModifiedSecs: 938716014
Parent: 7
SequenceNumber: 15
Title: How do I set the memory size of my JVM in automatic mode? (Out of memory exceptions)
Part: 0
Author-Set: cmcclanahan@@mytownnet.com
LastModifiedSecs: 924622740
Type: 
Lines: 5
In your "jserv.properties" file, add a setting like this:

wrapper.bin.parameters=-mx64m

to set the maximum heap size to 64 megabytes.
EndPart: 0
Part: 1
Author-Set: jon@@working-dogs.com
HideAttributions: 1
LastModifiedSecs: 926034600
Type: 
Lines: 78
From: Godmar Back <gback@@cs.utah.edu>
To: java-apache-users@@list.working-dogs.com
Subject: Re: Exceptions / Errors and catching unexpected ones.
Date: Thu, May 6, 1999, 4:44 PM

OutOfMemory exceptions are thrown when the JVM runs out of heap space,
not stack space.  By that time, the JVM will have tried to garbage
collect and drop weak refs already.  (Which, btw, the suggestion to 
invoke System.gc() in a catch(OutOfMemory ) clause does not work.)

Let me quote the VMSpec:

    3.5.3
        [...]

        If a computation requires more heap than can be made available by the 
        automatic storage management system, the Java virtual machine throws 
        an OutOfMemoryError

The only instance when lack of stack of space causes an out of memory error
is when the native method stack cannot be extended.
For your convenience, I quote the complete VMSpec subsection:

    3.5.6 Native Method Stacks

    An implementation of the Java virtual machine may use conventional 
    stacks, colloquially called "C stacks," to support native methods, 
    methods written in a language other than the Java programming language. 
    Native method stacks may also be used by the implementation of an 
    interpreter for the Java virtual machine's instruction set in a language 
    such as C. Java virtual machine implementations that cannot load native 
    methods and that do not themselves rely on conventional stacks need not 
    supply native method stacks. If supplied, native method stacks are 
    typically allocated per thread when each thread is created. 

    The Java virtual machine specification permits native method stacks 
    either to be of a fixed size or to dynamically expand and contract as 
    required by the computation. If the native method stacks are of a
    fixed size, the size of each native method stack may be chosen 
    independently when that stack is created. In any case, a Java virtual 
    machine implementation may provide the programmer or the user control 
    over the initial size of the native method stacks. In the case of 
    varying-size native method stacks, it may also make available control 
    over the maximum and minimum method stack sizes.7

    The following exceptional conditions are associated with native method 
    stacks:

        If the computation in a thread requires a larger native method 
        stack than is permitted, the Java virtual machine throws a 
        StackOverflowError. 

        If native method stacks can be dynamically expanded and native method 
        stack expansion is attempted but insufficient memory can be made 
        available, or if insufficient memory can be made available to create 
        the initial native method stack for a new thread, the Java virtual 
        machine throws an OutOfMemoryError. 

How do you know that what causes the out of memory error in the case
discussed was a failure to allocate more memory for the stack?
I would have thought that this would only happen if you set a *very* large
stack limit and then entered a buggy recursive function.

You may also want to try a VM that does not dynamically expand its stacks,
such as Kaffe.  If you still get an OutOfMemoryError (as opposed to a
StackOverflow) exception, you could be sure that not being able to expand
the stack has nothing to do with it the problem --- otherwise, you would
have gotten a StackOverflowError.

In general, reacting to OutOfMemoryErrors is hard.  First, you need a
VM that supports it (Kaffe currently doesn't, I don't think the JDK does
either.) The JVM has to throw the error at a point in time where there are
sufficient resources for the program to proceed to a point where it can
drop references (either by terminating threads or by explicitly dropping
(zeroing out) references) and then invoke a gc.  This is not trivial to
implement.

        - Godmar
EndPart: 1
Part: 2
Author-Set: Tom.Howland@@us.pwcglobal.com
HideAttributions: 1
LastModifiedSecs: 938716014
Type: html
Lines: 69
There are several things that one can do about out-of-memory errors. The best thing is to figure out why you are getting them. Jprobe might be useful in this regard. Unfortunately, that is not feasible for me. jserv will run for a month or two unattended before abruptly dying on an out-of-memory error.

<br><br>

I wrote a script that watches my jserv log and restarts the thing
if it starts getting servlet errors. This is brutal but effective
as far as I can tell. Here is my very nutty script:

<blockquote><small><code><pre>

#!/usr/local/bin/perl -w

# this is a lovely hack for recovering from Out Of Memory Errors in jserv

$log='/opt/apache/logs/jserv.log';
$ap='/opt/apache/bin/apachectl';

open(LOG, $log) || die "couldn't open $log: $!\n";

# jump to the end of the log

seek(LOG, 0, 2);
$| = 1;

# recover from log roll-overs by keeping track of the size of the log

$s = -s $log;

while(1){
  while(&lt;LOG&gt;){
    if(/\(ERROR\) ajp11\: Servlet Error\: /){
      next if $' =~ /ClassNotFoundException\:/;
      system("$ap stop") || die $!;
      sleep 1;
      system("$ap start") || die $!;
      sleep 1;
      system("$ap stop") || die $!;
      sleep 1;
      seek(LOG, 0, 2);
      system("$ap start") || die $!;
      my @@lt = localtime(time);
      printf("%d/%.2d/%.2d %.2d:%.2d:%.2d $'\n", $lt[5] + 1900, $lt[4] + 1, $lt[3], $lt[2], $lt[1], $lt[0]);
    }
  }
  seek(LOG, 0, 1);
  sleep 1;
  my $s1 = -s $log;
  if(defined($s1)){
    if($s1 &lt; $s){
      close(LOG);
      open(LOG, $log);
    }
    $s = $s1;
  }
}

</pre></code></small></blockquote>

The other solution that has been <a href="http://www.mail-archive.com/java-apache-users@@list.working-dogs.com/msg04691.html">bandied about in the mailing list</a> is to modify memory usage of the jvm. I guess that means modifying jserv.properties so that 

<code>
wrapper.bin.parameters=-Xms128m -Xmx156m
</code>

for Java 2.

<br><br>

<address><a href="mailto:Tom.Howland@@us.pwcglobal.com">Tom Howland</a></address>
EndPart: 2
@


1.21
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938715865
d9 1
a9 1
SequenceNumber: 14
d110 1
a110 1
LastModifiedSecs: 938715865
d112 2
a113 12
Lines: 79
There are several things that one can do about out-of-memory errors.

<br><br>

The best thing is to figure out why you are getting them. Jprobe
might be useful in this regard.

<br><br>

Unfortunately, that is not feasible for me. jserv will run for a month
or two unattended before abruptly dying on an out-of-memory error.
d119 1
a119 1
as far as I can tell.
d121 1
a122 2
Here is my very nutty script:
<blockquote><small><code><pre>
d168 1
d171 2
a172 3
The other solution that has been <a href="http://www.mail-archive.com/java-apache-users@@list.working-dogs.com/msg04691.html">bandied about in the mailing list</a> is to modify memory
usage of the jvm. I guess that means modifying jserv.properties so
that 
d176 1
@


1.20
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938715458
d9 1
a9 1
SequenceNumber: 13
d110 1
a110 1
LastModifiedSecs: 938715458
d162 1
a178 1

@


1.19
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938715137
d9 1
a9 1
SequenceNumber: 12
d110 1
a110 1
LastModifiedSecs: 938715137
d112 1
a112 1
Lines: 77
d170 6
a175 3
  if($s1 &lt; $s){
    close(LOG);
    open(LOG, $log);
a176 1
  $s = $s1;
@


1.18
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938714734
d9 1
a9 1
SequenceNumber: 11
d110 1
a110 1
LastModifiedSecs: 938714734
d153 1
a153 1
  while(<LOG>){
d170 1
a170 1
  if($s1 < $s){
@


1.17
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938714584
d9 1
a9 1
SequenceNumber: 10
d110 1
a110 1
LastModifiedSecs: 938714584
d112 1
a112 1
Lines: 75
d179 1
a179 1
The other solution that has been bandied about is to modify memory
d186 2
@


1.16
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938714343
d9 1
a9 1
SequenceNumber: 9
d110 1
a110 1
LastModifiedSecs: 938714343
a130 9
<br><br>

The other solution that has been bandied about is to modify memory
usage of the jvm. I guess that means modifying jserv.properties so
that 
<code>
wrapper.bin.parameters=-Xms128m -Xmx156m
</code>
for Java 2.
d133 1
a133 1
<code>
d176 8
d185 1
@


1.15
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938714242
d9 1
a9 1
SequenceNumber: 8
d110 2
a111 1
LastModifiedSecs: 938714242
@


1.14
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 938714052
d9 1
a9 1
SequenceNumber: 7
d110 2
a111 2
LastModifiedSecs: 938714052
Lines: 67
d114 2
d119 2
d124 2
d130 2
d135 1
a135 1

d137 1
a137 1

d141 1
a141 1

d184 1
d186 1
a186 2

- Tom Howland
@


1.13
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 926034609
d9 1
a9 1
SequenceNumber: 6
d107 73
@


1.12
log
@null
@
text
@a23 1
DateOfPart: 1999-May-06  4:50pm
d25 2
@


1.11
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 926034572
d9 1
a9 1
SequenceNumber: 5
d22 84
@


1.10
log
@null
@
text
@d7 1
a7 1
LastModifiedSecs: 924719380
d9 2
a10 2
SequenceNumber: 4
Title: How do I set the memory size of my JVM in automatic mode?
@


1.9
log
@null
@
text
@d3 1
@


1.8
log
@null
@
text
@a2 1
IDependOn-Set: 121
@


1.7
log
@null
@
text
@d3 1
@


1.6
log
@null
@
text
@d6 1
a6 1
LastModifiedSecs: 924656181
d8 1
a8 1
SequenceNumber: 3
a20 13
Part: 1
Author-Set: simon@@principia.edu
LastModifiedSecs: 924656160
Type: 
Lines: 7
Does anyone know what the standard memory allocated to the JVM is?
How can you tell how much memory has been used by a Servlet when it
is currently running?  Is this even possible?

I have a large servlet that has been running fine for many months,
but it has recently been hanging/crashing and I want to see if it
needs more memory but don't know how to figure this out?
EndPart: 1
@


1.5
log
@null
@
text
@d23 2
a24 1
DateOfPart: 1999-Apr-20  5:56pm
@


1.4
log
@null
@
text
@d6 1
a6 1
LastModifiedSecs: 924622794
d8 1
a8 1
SequenceNumber: 2
d12 2
a13 1
DateOfPart: 1999-Apr-20  8:39am
d21 12
@


1.3
log
@null
@
text
@d6 1
a6 1
LastModifiedSecs: 924622728
d8 1
a8 1
SequenceNumber: 1
d10 10
@


1.2
log
@null
@
text
@d6 1
a6 1
LastModifiedSecs: 924622607
d8 2
a9 2
SequenceNumber: 0
Title: New Item
@


1.1
log
@null
@
text
@d5 1
@
