Difficulty setting Solr JVM memory settings on Ubuntu with Bitnami AMI - java

I am using the Apache Solr powered by BitNami EC2 AMI. Solr is running, but I'd like to change the startup configuration to increase the amount of memory allocated to JVM.
I have tried modifying the startup script at at /opt/bitnami/apache-solr/scripts/ctl.sh by modifying the following line:
SOLR="$JAVABIN -Dsolr.solr.home=$SOLR_HOME
-Djetty.logs=$INSTALL_PATH/logs/ -Djetty.home=$INSTALL_PATH/ -jar $INSTALL_PATH/start.jar $INSTALL_PATH/etc/jetty.xml"
I've tried different permutations for the memory flags and none of them work (some of them cause the Solr server to fail to start at all, while others allow it to start but have no effect on the JVM memory allocated). This is what I've tried adding to the line:
-Xmx 1000 -Xms 8000
-Xms1000m -Xmx8000m
-Xms1000 -Xmx8000
-Xms 1000m -Xmx 8000m
What is the correct way of going about this?

It turns out that the arguments needed to be at the start of the line. The following works:
SOLR="$JAVABIN -Xmx7168m -Xms1024m -Dsolr.solr.home=$SOLR_HOME
-Djetty.logs=$INSTALL_PATH/logs/ -Djetty.home=$INSTALL_PATH/ -jar $INSTALL_PATH/start.jar $INSTALL_PATH/etc/jetty.xml"

Related

Subgit "Out of Memory" and "GC Overhead Limit Exceeded"

I’m running a conversion project from svn to git. As the application is single threaded, I’m moving the project to a Faster PC.
So without any options bar httpSpooling = true; It runs OK on a VM – 4 CPU's, 20 Gb of Ram.
RAM Usage with two separate instances is 8GB, hitting a max of 9.8Gb.
Jobs Paused, Zipped & SCP'd to new machine – Bare Metal build of Deb9 (same as VM) i7 (8 CPUs(effective)) 16GB ram.
However when starting just one instance of SubGit; I get either Java out of memory or GC Overhead Limit Exceeded.
I’ve tried adding the following permutations to repo.git/subgit/config to [daemon]
javaOptions = -noverify -client -Djava.awt.headless=true -Xmx8g -XX:+UseParallelGC -XX:-UseGCOverheadLimit – This gives GC Overhead Limit Exceeded Error
#javaOptions = -noverify -client -Djava.awt.headless=true -Xmx8g -XX:+UseParallelGC -XX:-UseGCOverheadLimit – (OPS Disabled) Gives an out of memory error.
javaOptions = -noverify -client -Djava.awt.headless=true –Xmx12g -XX:-UseGCOverheadLimit – this gives out of memory errors.
I’ve tried other settings too, including changing –client for –server, but that appears to be more two way conversion, which is not something I’m trying to do.
There should be plenty of RAM based on the application usage on a system running successfully, so unless SubGit is ignoring some values, I can’t tell.
The 'javaOptions' in the [daemon] section may indeed be ignored depending on the operation you run: those java options affect SubGit daemon, but not the 'subgit install' or 'subgit fetch' operation. Since you've mentioned that repositories were moved to another machine, I believe, you have invoked either of those two commands to restart the mirror and that's why that 'daemon.javaOptions' is ignored. To tune SubGit's java options edit it right in the SubGit launching script (EXTRA_JVM_ARGUMENTS line):
EXTRA_JVM_ARGUMENTS="-Dsun.io.useCanonCaches=false -Djava.awt.headless=true -Djna.nosys=true -Dsvnkit.http.methods=Digest,Basic,NTLM,Negotiate -Xmx512m"
As for the memory consumption itself, it depends on which operations are being run. It's not completely clear how did you pause the jobs on the virtual machine (by 'subgit shutdown' or in another way?), which operations were running at that time (initial translation or regular fetches) and how did you restart the jobs on the new machine.

-XX:MaxPermSize=128m: command not found when setting MaxPermSize on linux server

Getting this kind of error on linux server in my project when i run my spring-hibernate project
i read the
Increase permgen space
someone replied to execute
-XX:MaxPermSize=128m
to increase of MaxPermSize but when i execute this command in in my
project under directory of classes i got an error
[root#server classes]# -XX:MaxPermSize=128m
-bash: -XX:MaxPermSize=128m: command not found
Initial SessionFactory creation failed.java.lang.OutOfMemoryError: PermGen space
How can I set MaxPermSize only for one particular project as I am working on live server some projects are live on that server so please suggest me right solution so that I can set MaxPermSize on live server
You misunderstood the answer on the original question.
When you run a Java program, you use a command like:
java [JVM arguments] ClassName [program arguments]
The --XX:MaxPermSize=128m part goes in the "JVM arguments" part - it is a directive to the JVM to allocate 128m of memory to the PermGen.
So you are supposed to edit the java command in your script and not put that argument on a separate line.
You should also consider upgrading to Java 8, in which Permgen no longer exists.
-XX:MaxPermSize=128m is a JVM argument, not a bash command.

Read pdf using java

i have a problem with reading PDF file content in java using itextpdf.jar ,
if i read a small sized(5-15MB) PDF file means its working well, it is possible to read it's contents
but when i read large sized(200MB) PDF file means its showing Run time exception like following
enter code hereException in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.InputStreamToArray(RandomAccessFileOrArray.java:213)
at com.itextpdf.text.pdf.RandomAccessFileOrArray.<init>(RandomAccessFileOrArray.java:203)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:235)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:246)
at general.FileStreamClose.main(FileStreamClose.java:28)
Java Result: 1enter code here
any solution for this , how to increase heap size in tomcat
You can tune your Java Application Runtime settings:
maximize heap size to high value with -Xmx say 500M
tune -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio to make sure that the application will not becomes irresponsive when consuming lot of memory when the heap reduces.
to increase heap size for tomcat you'll have to set the evnirenment variable JAVA_OPTS and have it contain the -Xmx option for example -Xmx512m
here is a sample script how you can run tomcat
#echo off
set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_33
set CATALINA_HOME=C:\Program Files\apache-tomcat-7.0
set JAVA_OPTS=-XX:MaxPermSize=128m -Xmx512m -server
call %CATALINA_HOME%\bin\catalina.bat run
for additional info, as far as i know, if your machine is 32 bit increase xmx and xms heap size will limited around 1k++. If you need more than that you need to install java 64 bit (of course in 64 machine and 64 OS).

java.lang.OutOfMemoryError: Java heap space with NetBeans

This is the error I get when I run my web application in an instance of the Tomcat servlet container started by NetBeans. To fix this I even changed the heap size in netbeans.conf, but still it shows the same error. How can I keep this from happening?
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
root cause
java.lang.OutOfMemoryError: Java heap space
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
Changing the heap size in netbeans.conf only changes the heap for NetBeans itself, not for applications run through NetBeans.
The correct way is to right-click on the project and select "Properties" and then "Run"; there you can set the VM options appropriately (-Xmx256m, for instance). It should look something like this:
(Thanks to VonC for finding this picture.)
Stop Tomcat server, set environment variable CATALINA_OPTS, and then restart Tomcat. Look at the file tomcat-install/bin/catalina.sh or catalina.bat for how this variable is used. For example,
set CATALINA_OPTS="-Xms512m -Xmx512m" (Windows)export CATALINA_OPTS="-Xms512m -Xmx512m" (ksh/bash)setenv CATALINA_OPTS "-Xms512m -Xmx512m" (tcsh/csh)
In catalina.bat or catallina.sh, you may have noticed CATALINA_OPTS, JAVA_OPTS, or both can be used to specify Tomcat JVM options.
What is the difference between CATALINA_OPTS and JAVA_OPTS?
The name CATALINA_OPTS is specific for Tomcat servlet container, whereas JAVA_OPTS may be used by other java applications (e.g., JBoss). Since environment variables are shared by all applications, we don't want Tomcat to inadvertently pick up the JVM options intended for other apps. I prefer to use CATALINA_OPTS.
How to set java heap size in JBoss?
Stop JBoss server, edit $JBOSS_HOME/bin/run.conf, and then restart JBoss server. You can change the line with JAVA_OPTS to something like:
JAVA_OPTS="-server -Xms128m -Xmx128m"
How to set java heap size in Eclipse?
You have 2 options:
Edit eclipse-home/eclipse.ini to be something like the following and
restart Eclipse.
-vmargs-Xms64m-Xmx256m
Or, you can just run eclipse command with additional options at the
very end. Anything after -vmargs will be treated as JVM options and
passed directly to the JVM. JVM options specified in the command
line this way will always override those in eclipse.ini. For
example,
eclipse -vmargs -Xms64m -Xmx256m
How to set java heap size in NetBeans?
Exit NetBeans, edit the file netbeans-install/etc/netbeans.conf. For example,
netbeans_default_options="-J-Xms512m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=128m -J-Xverify:none
How to set java heap size in Apache Ant?
Set environment variable ANT_OPTS. Look at the file $ANT_HOME/bin/ant or %ANT_HOME%\bin\ant.bat, for how this variable is used by Ant runtime.
set ANT_OPTS="-Xms512m -Xmx512m" (Windows)export ANT_OPTS="-Xms512m -Xmx512m" (ksh/bash)setenv ANT_OPTS "-Xms512m -Xmx512m" (tcsh/csh)
If you increase the virtual memory of your Tomcat server then it will be OK.
Steps:
In NB go through the windows menu and add Services
You will find Tomcat in the services. Right click on Tomcat server and select Properties
Go to the platform in the properties and write -Xms512m in VM options field
I'm guessing that increasing the memory won't fix the problem. What is that MonitorFilter doing? What's eating up all that memory?
Your best bet is to figure that out. If this is a web app, see if you can turn off that filter and run without it. If you have success, you know that the MonitorFilter is causing your to fail.
This has nothing to do with NetBeans (well, perhaps), rather it has to do with Tomcat. Tomcat is the process that is running out of heap, not NetBeans. Track down the startup process for your Tomcat. If it's bundled with NB, then Tomcat is buried within the NB installation, check for an "enterpriseN" directory, N being a number, Tomcat is probably in there and it's a rather generic distribution of it.
As to why the monitor is run OOM, that's hard to say, it's a pretty simple process when you think about it. You can also try disabling HTTP monitoring to see if it's a problem with the Monitoring itself or something with your application.

Is there a way to increase virtual memory in an application started from NetBeans?

In my project I often encounter Java heap space errors, i.e., there isn't enough space to run the program any more. Is there any way I can increase virtual memory?
I am not using the command-line. I am using Net Beans.
In NetBeans, you can add command line options using the Properties of the Project, the Run option. There is an option for the JVM command line there. Look at the -Xms and -Xmx options.
This works for JRuby projects as well, incidentally.
Under Netbeans you can set the VM options for a project, in the project properties. Under Properties > Run the last box should be VM Options. Netbeans will use those when running the app.
Java -X, read about java -Xms and -Xmx
Use the command line arguments when invoking JVm as,
java -Xms -Xmx
Running JAR directly is on longer suggested (from Sun) (someone may disagree).
You are suggested to use WebStart/JNLP, applet, or exe/batch wrapper that you can control the startup behaviour of the JVM.
The another way you can do is that implement your own wrapper in Java. i.e. fork the real java.exe with -Xmx in your main() function.

Categories

Resources