Download Servlet throwing Out Of Memory Exception
I am trying to download file of more than 500 mb through servlet but getting out of memory exception .
Before downloading i am zipping that huge file .
try {
String zipFileName = doZip(file);
file =null;
System.gc();
File inputFile = new File(zipFileName);
InputStream fileToDownload = new FileInputStream(
inputFile);
response.setContentType("application/zip");
response.setHeader("Content-Disposition","attachment; filename=\""
+ fileName.replaceAll("tmx", "zip")
.concat("\""));
response.setContentLength(fileToDownload.available());
byte buf[] = new byte[BUF_SIZE];
int read;
while ((read = fileToDownload.read(buf)) != -1) {
outs.write(buf, 0, read);
fileToDownload.close();
outs.flush();
outs.close();
}catch(Exception e ) {
//Getting out of memory.
}Please suggest solution for this .
cotton.m wrote:
My zip suggestion was as follows.
Take the file. Do not set the Content length header. Do set the Content encoding header to gzip. Create a GZIP output stream using the servlet output stream. Read the unzipped file in and output it through the gzip output stream.
This cuts out one full cycle of file reading and writing from what you are doing currently.Thanks for u r reply
InputStream fileToDownload = new FileInputStream(
file);
response.setContentType("application/gzip");
response.setHeader("Transfer-Encoding", "chunked");
response.setContentLength((int) file.length());
GZIPOutputStream gzipoutputstream = new GZIPOutputStream(outs);
byte buf[] = new byte[BUF_SIZE];
int read;
while ((read = fileToDownload.read(buf)) != -1) {
gzipoutputstream.write(buf, 0, read);
fileToDownload.close();
outs.flush();
outs.close();I made changes accordingly . Please provide u r view on this .
Similar Messages
-
URLStream.readBytes always throw out of memory exception (errorID=1000)
When I try to load a file as 180MBytes by using URLStream.readBytes().
In some PCs, it's OK.
But in some PCs, there are always [out of memory] exception (errorID=1000) even such PC still had enough memory.
For example:
Total memory is 2G, current used is 1.43G, but URLStream.readBytes() still throw such exception.
For file with little size such as 30M, there isn't such problem.
Could any body give some suggestion?
Best regards,
Sourcecode is very simple like:
var myStream:URLStream;
var inputBytes: ByteArray = new ByteArray();
... do load ...
// load by progressive event. I only deal progress load once, and ignore all later progressive load events.
// for example first 500KBytes was read.
myStream(inputBytes,inputBytes.length);
// load again when all datas is loaded completely. For example, 180MBytes should be read.
try {
myStream(inputBytes,inputBytes.length);
} catch(e:*) {
// warning logWhen I try to load a file as 180MBytes by using URLStream.readBytes().
In some PCs, it's OK.
But in some PCs, there are always [out of memory] exception (errorID=1000) even such PC still had enough memory.
For example:
Total memory is 2G, current used is 1.43G, but URLStream.readBytes() still throw such exception.
For file with little size such as 30M, there isn't such problem.
Could any body give some suggestion?
Best regards,
Sourcecode is very simple like:
var myStream:URLStream;
var inputBytes: ByteArray = new ByteArray();
... do load ...
// load by progressive event. I only deal progress load once, and ignore all later progressive load events.
// for example first 500KBytes was read.
myStream(inputBytes,inputBytes.length);
// load again when all datas is loaded completely. For example, 180MBytes should be read.
try {
myStream(inputBytes,inputBytes.length);
} catch(e:*) {
// warning log -
Uploading large files from applet to servlet throws out of memory error
I have a java applet that needs to upload files from a client machine
to a web server using a servlet. the problem i am having is that in
the current scheme, files larger than 17-20MB throw an out of memory
error. is there any way we can get around this problem? i will post
the client and server side code for reference.
Client Side Code:
import java.io.*;
import java.net.*;
// this class is a client that enables transfer of files from client
// to server. This client connects to a servlet running on the server
// and transmits the file.
public class fileTransferClient
private static final String FILENAME_HEADER = "fileName";
private static final String FILELASTMOD_HEADER = "fileLastMod";
// this method transfers the prescribed file to the server.
// if the destination directory is "", it transfers the file to
"d:\\".
//11-21-02 Changes : This method now has a new parameter that
references the item
//that is being transferred in the import list.
public static String transferFile(String srcFileName, String
destFileName,
String destDir, int itemID)
if (destDir.equals(""))
destDir = "E:\\FTP\\incoming\\";
// get the fully qualified filename and the mere filename.
String fqfn = srcFileName;
String fname =
fqfn.substring(fqfn.lastIndexOf(File.separator)+1);
try
//importTable importer = jbInit.getImportTable();
// create the file to be uploaded and a connection to
servlet.
File fileToUpload = new File(fqfn);
long fileSize = fileToUpload.length();
// get last mod of this file.
// The last mod is sent to the servlet as a header.
long lastMod = fileToUpload.lastModified();
String strLastMod = String.valueOf(lastMod);
URL serverURL = new URL(webadminApplet.strServletURL);
URLConnection serverCon = serverURL.openConnection();
// a bunch of connection setup related things.
serverCon.setDoInput(true);
serverCon.setDoOutput(true);
// Don't use a cached version of URL connection.
serverCon.setUseCaches (false);
serverCon.setDefaultUseCaches (false);
// set headers and their values.
serverCon.setRequestProperty("Content-Type",
"application/octet-stream");
serverCon.setRequestProperty("Content-Length",
Long.toString(fileToUpload.length()));
serverCon.setRequestProperty(FILENAME_HEADER, destDir +
destFileName);
serverCon.setRequestProperty(FILELASTMOD_HEADER, strLastMod);
if (webadminApplet.DEBUG) System.out.println("Connection with
FTP server established");
// create file stream and write stream to write file data.
FileInputStream fis = new FileInputStream(fileToUpload);
OutputStream os = serverCon.getOutputStream();
try
// transfer the file in 4K chunks.
byte[] buffer = new byte[4096];
long byteCnt = 0;
//long percent = 0;
int newPercent = 0;
int oldPercent = 0;
while (true)
int bytes = fis.read(buffer);
byteCnt += bytes;
//11-21-02 :
//If itemID is greater than -1 this is an import file
transfer
//otherwise this is a header graphic file transfer.
if (itemID > -1)
newPercent = (int) ((double) byteCnt/ (double)
fileSize * 100.0);
int diff = newPercent - oldPercent;
if (newPercent == 0 || diff >= 20)
oldPercent = newPercent;
jbInit.getImportTable().displayFileTransferStatus
(itemID,
newPercent);
if (bytes < 0) break;
os.write(buffer, 0, bytes);
os.flush();
if (webadminApplet.DEBUG) System.out.println("No of bytes
sent: " + byteCnt);
finally
// close related streams.
os.close();
fis.close();
if (webadminApplet.DEBUG) System.out.println("File
Transmission complete");
// find out what the servlet has got to say in response.
BufferedReader reader = new BufferedReader(
new
InputStreamReader(serverCon.getInputStream()));
try
String line;
while ((line = reader.readLine()) != null)
if (webadminApplet.DEBUG) System.out.println(line);
finally
// close the reader stream from servlet.
reader.close();
} // end of the big try block.
catch (Exception e)
System.out.println("Exception during file transfer:\n" + e);
e.printStackTrace();
return("FTP failed. See Java Console for Errors.");
} // end of catch block.
return("File: " + fname + " successfully transferred.");
} // end of method transferFile().
} // end of class fileTransferClient
Server side code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.net.*;
// This servlet class acts as an FTP server to enable transfer of
files
// from client side.
public class FtpServerServlet extends HttpServlet
String ftpDir = "D:\\pub\\FTP\\";
private static final String FILENAME_HEADER = "fileName";
private static final String FILELASTMOD_HEADER = "fileLastMod";
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException
doPost(req, resp);
public void doPost(HttpServletRequest req, HttpServletResponse
resp)
throws ServletException,
IOException
// ### for now enable overwrite by default.
boolean overwrite = true;
// get the fileName for this transmission.
String fileName = req.getHeader(FILENAME_HEADER);
// also get the last mod of this file.
String strLastMod = req.getHeader(FILELASTMOD_HEADER);
String message = "Filename: " + fileName + " saved
successfully.";
int status = HttpServletResponse.SC_OK;
System.out.println("fileName from client: " + fileName);
// if filename is not specified, complain.
if (fileName == null)
message = "Filename not specified";
status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
else
// open the file stream for the file about to be transferred.
File uploadedFile = new File(fileName);
// check if file already exists - and overwrite if necessary.
if (uploadedFile.exists())
if (overwrite)
// delete the file.
uploadedFile.delete();
// ensure the directory is writable - and a new file may be
created.
if (!uploadedFile.createNewFile())
message = "Unable to create file on server. FTP failed.";
status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
else
// get the necessary streams for file creation.
FileOutputStream fos = new FileOutputStream(uploadedFile);
InputStream is = req.getInputStream();
try
// create a buffer. 4K!
byte[] buffer = new byte[4096];
// read from input stream and write to file stream.
int byteCnt = 0;
while (true)
int bytes = is.read(buffer);
if (bytes < 0) break;
byteCnt += bytes;
// System.out.println(buffer);
fos.write(buffer, 0, bytes);
// flush the stream.
fos.flush();
} // end of try block.
finally
is.close();
fos.close();
// set last mod date for this file.
uploadedFile.setLastModified((new
Long(strLastMod)).longValue());
} // end of finally block.
} // end - the new file may be created on server.
} // end - we have a valid filename.
// set response headers.
resp.setContentType("text/plain");
resp.setStatus(status);
if (status != HttpServletResponse.SC_OK)
getServletContext().log("ERROR: " + message);
// get output stream.
PrintWriter out = resp.getWriter();
out.println(message);
} // end of doPost().
} // end of class FtpServerServletOK - the problem you describe is definitely what's giving you grief.
The workaround is to use a socket connection and send your own request headers, with the content length filled in. You may have to multi-part mime encode the stream on its way out as well (I'm not about that...).
You can use the following:
http://porsche.cis.udel.edu:8080/cis479/lectures/slides-04/slide-02.html
on your server to get a feel for the format that the request headers need to take.
- Kevin
I get the out of Memory Error on the client side. I
was told that this might be a bug in the URLConnection
class implementation that basically it wont know the
content length until all the data has been written to
the output stream, so it uses an in memory buffer to
store the data which basically causes memory issues..
do you think there might be a workaround of any kind..
or maybe a way that the buffer might be flushed after
a certain size of file has been uploaded.. ?? do you
have any ideas? -
Openscript throws out of memory exception
Hi,
I see the following exceptions very frequently while using open script 12.3.0.1:
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: PermGen space
I have increases the vmargs values in the eclipse.ini of OracleATS/openscript folder where OATS is installed on my machine.
-startup
plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20080819.jar
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
2048m
-vmargs
-Xms512m
-Xmx4096m
-XX:MaxPermSize=2048m
I have also tried two other ways like setting JAVA_OPTS in environment variables and heap space in the control panel for java, but nothing worked for me.
Note: I use windows7.
Thanks,
suseela.Hi Guys,
Will PreparedStatement.addBatch() throw Out of
f Memory EXception??It depends on how many objects are created during that method's execution and how much heap is left at the time you call it.
Current i m populate 3000 update statement and
nd using addBatch() method and execute at the end and
it works fine for me...
I m just wondering what if i have like 100.000
00 record or something??
Any Idea??It depends.
Try it and see.
And if it works one time, don't assume it will next time, unless your code and its data are very regular. -
Oracle BPM installed Java out-of-memory exception
Hi,
I have installed the oracle BPM software in the server have the Ram capacity 8 GB,Could you please suggest some of the do's and don't's to avoid the Java out-of-memory exception which normally appearing on the console of weblogic server.
My Server details,
Windows 2008 R2 64 bit, RAM 8 GB,
The required BPM s/w I installed from the link below,
http://www.oracle.com/technetwork/middleware/bpm/downloads/index.html?ssSourceSiteId=ocomen
Thanks in advance for your help.
Regards,
Shyam
Edited by: user13821489 on 06-Feb-2011 22:45I had to increase JVM xmx/maxperm in the "set*Env.sh" scripts in the directory where you start WLS. In my dev environment, deploying BAM & BPM together with the Admin server, I finally allocated 4GB max. Jdev.conf is also better if you allocate > 1GB - mine is 1.4GB. I also watch process memory. Multiple re-deployments in my development environment seem to increase the memory, even if I remove process instances and undeploy first. I don't understand the internals very well so perhaps it is behaving correctly, but restarting WLS frees the unused memory that I expected gc to reclaim.
-
Large DataTable causes out of memory exception
Hello Support
We have a datatable that returns 112970 records and have 51 columns.
When we try generate an xls file or display data result in grid view than "System Out of memory exception" is thrown.
OS : Windows 2003 Enterprise 32 Bit
HP DL380 G4
CPU 2x3.6GHZ
6 GB RAM
Can you help us to find a resolution to this issue?
Thank you
Shrenik
MauriceThanks for reply.
1> .XLXS format allows us >= 133000 records in spread sheet some times and some times it throws Exception of type 'System.OutOfMemoryException'.
2> We are using asp.net gridview.
Exception:
ExceptionObject : Message : Exception of type 'System.OutOfMemoryException' was thrown.
Data : System.Collections.ListDictionaryInternal
InnerException : Nothing
TargetSite : System.String ToBase64String(Byte[], Int32, Int32, System.Base64FormattingOptions)
StackTrace : at System.Convert.ToBase64String(Byte[] inArray, Int32 offset, Int32 length, Base64FormattingOptions options)
at System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph, Purpose purpose)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Serialize(Object state, Purpose purpose)
at System.Web.UI.Util.SerializeWithAssert(IStateFormatter2 formatter, Object stateGraph, Purpose purpose)
at System.Web.UI.HiddenFieldPageStatePersister.Save()
at System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state)
at System.Web.UI.Page.SaveAllState()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) HelpLink : Nothing Source : mscorlib HResult : -2147024882
Please see below code for more information.
protected void Button1_Click(object sender, EventArgs e)
try
DataTable _dt = GetDataFromDB();
ViewState["dtQueryResults"] = _dt;
BindgvQueryResults();
messageLabel.Text = "";
catch (Exception ex)
messageLabel.Text = "Query execute error: " + ex.Message;
private void BindgvQueryResults()
if (ViewState["dtQueryResults"] != null)
DataView _dv = ((DataTable)ViewState["dtQueryResults"]).DefaultView;
if (ViewState["gvQRSortExpression"] != null && ViewState["gvQRSortDirection"] != null)
_dv.Sort = ViewState["gvQRSortExpression"].ToString() + ViewState["gvQRSortDirection"].ToString();
gvQueryResults.DataSource = _dv;
gvQueryResults.DataBind();
private DataTable GetDataFromDB()
SqlCommand _Cmd = null;
SqlConnection _Con = null;
try
_Con = DBInteraction.InstantiateConnection();
_Cmd = new SqlCommand();
_Cmd.Connection = _Con;
_Cmd.CommandTimeout = 300;
if (_Con.State != ConnectionState.Open)
_Con.Open();
try
_Cmd.CommandText = CriteriaBuilder1.QueryTransformer.Sql;
catch(NullReferenceException)
throw new ApplicationException("Error message.");
if(string.IsNullOrEmpty(CriteriaBuilder1.QueryTransformer.Sql))
throw new ApplicationException("This query does not have any text. Please add views in the query and try again.");
_Cmd.CommandType = CommandType.Text;
DataTable _dt = new DataTable();
SqlDataAdapter adaPTer = new SqlDataAdapter(_Cmd);
adaPTer.AcceptChangesDuringFill = false;
adaPTer.Fill(_dt);
if (_dt.Rows.Count == 0)
throw new ApplicationException("Your request did not return any results.");
return _dt;
catch (Exception ex)
throw ex;
finally
if (_Con.State == ConnectionState.Open)
_Con.Close();
Maurice -
Getting an Out of memory exception while validating XML against XSD
Hello friends,
I am getting an Out Of Memory exception while validating my XML against a given XSd which is huge.
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",new File("C:/todelxsd.xsd")); as u may see the darkened code. this basically Loads the XSD in Memmory , and JVM throws an out of Memory exception. is there any other way round of validating an XML against an XSD where i dont have to load my XSD if not then kindly let me know the solution for above problem .
Thanks.Yes, but increasing the heap size is a temporary solution , isnt there a way where the XML can be validated against an XSD without having to load XSD in memory
-
Getting an out of memory exception while validating my XML against a XSD
Hello friends,
I have asked this question in following thread too. Pasting it again here just to saye your time
http://forum.java.sun.com/thread.jspa?threadID=690812&tstart=0
I am getting an Out Of Memory exception while validating my XML against a given XSd which is huge.
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",new File("C:/todelxsd.xsd")); as u may see the darkened code. this basically Loads the XSD in Memmory , and JVM throws an out of Memory exception. is there any other way round of validating an XML against an XSD where i dont have to load my XSD if not then kindly let me know the solution for above problem .
Thanks.Yes, but increasing the heap size is a temporary solution , isnt there a way where the XML can be validated against an XSD without having to load XSD in memory
-
Out of memory exception in win2kServer
I have written a JAVA program to read an AutoCAD DXF file and grapgically display the contents as in AutoCAD. Whwn i try to pass a particular file ( say 15MB)
the JVM gives out of memory exception in Win2k Advance Server ( it takes about 70MB ) before throwing the error.
This machine has 256 mb , but in another machine whivh runs win2K profesional with128Mb opens the file without any error nd only consumes 35MB.
I use the same JVM in both machines( jdk1.3.0)
is this because of any bugs in resource allcation in the win2k ServerHave you added the -Xmx command line option to expand the default amount of memory that the JVM is allowed to allocate? Run 'java -X' for help
-
XSOMParser throwing out of memory error
Hello,
Currently we are using XSOM parser with DomAnnotationParserFactory to parse XSD file. For small files it is working fine. However is was throwing out of memory error while parsing 9MB file. We could understood reason behind this. Is there any way to resolve this issue?
Code :
XSOMParser parser = new XSOMParser();
parser.setAnnotationParser(new DomAnnotationParserFactory());
XSSchemaSet schemaSet = null;
XSSchema xsSchema = null;
parser.parse(configFilePath);
Here we are getting error on parser.parse() method. (using 128 MB heap memory using -Xrs -Xmx128m).
Stack Trace :
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at oracle.xml.parser.v2.XMLDocument.xdkIncCurrentId(XMLDocument.java:3020)
at oracle.xml.parser.v2.XMLNode.xdkInit(XMLNode.java:2758)
at oracle.xml.parser.v2.XMLNode.<init>(XMLNode.java:423)
at oracle.xml.parser.v2.XMLNSNode.<init>(XMLNSNode.java:144)
at oracle.xml.parser.v2.XMLElement.<init>(XMLElement.java:373)
at oracle.xml.parser.v2.XMLDocument.createNodeFromType(XMLDocument.java:2865)
at oracle.xml.parser.v2.XMLDocument.createElement(XMLDocument.java:1896)
at oracle.xml.parser.v2.DocumentBuilder.startElement(DocumentBuilder.java:224)
at oracle.xml.parser.v2.XMLElement.reportStartElement(XMLElement.java:3188)
at oracle.xml.parser.v2.XMLElement.reportSAXEvents(XMLElement.java:2164)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:337)
at oracle.xml.jaxp.JXTransformerHandler.endDocument(JXTransformerHandler.java:141)
at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:267)
at org.xml.sax.helpers.XMLFilterImpl.endElement(Unknown Source)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1257)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:314)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:281)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:196)
at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
at com.sun.xml.xsom.parser.JAXPParser.parse(JAXPParser.java:79)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:298)
at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:87)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:147)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:136)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:129)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:122)
Please let me know if anyone has comment on this.
Also let me know if there any other parser which handles large input files efficiently.Hello,
Currently we are using XSOM parser with DomAnnotationParserFactory to parse XSD file. For small files it is working fine. However is was throwing out of memory error while parsing 9MB file. We could understood reason behind this. Is there any way to resolve this issue?
Code :
XSOMParser parser = new XSOMParser();
parser.setAnnotationParser(new DomAnnotationParserFactory());
XSSchemaSet schemaSet = null;
XSSchema xsSchema = null;
parser.parse(configFilePath);
Here we are getting error on parser.parse() method. (using 128 MB heap memory using -Xrs -Xmx128m).
Stack Trace :
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at oracle.xml.parser.v2.XMLDocument.xdkIncCurrentId(XMLDocument.java:3020)
at oracle.xml.parser.v2.XMLNode.xdkInit(XMLNode.java:2758)
at oracle.xml.parser.v2.XMLNode.<init>(XMLNode.java:423)
at oracle.xml.parser.v2.XMLNSNode.<init>(XMLNSNode.java:144)
at oracle.xml.parser.v2.XMLElement.<init>(XMLElement.java:373)
at oracle.xml.parser.v2.XMLDocument.createNodeFromType(XMLDocument.java:2865)
at oracle.xml.parser.v2.XMLDocument.createElement(XMLDocument.java:1896)
at oracle.xml.parser.v2.DocumentBuilder.startElement(DocumentBuilder.java:224)
at oracle.xml.parser.v2.XMLElement.reportStartElement(XMLElement.java:3188)
at oracle.xml.parser.v2.XMLElement.reportSAXEvents(XMLElement.java:2164)
at oracle.xml.jaxp.JXTransformer.transform(JXTransformer.java:337)
at oracle.xml.jaxp.JXTransformerHandler.endDocument(JXTransformerHandler.java:141)
at com.sun.xml.xsom.impl.parser.state.NGCCRuntime.endElement(NGCCRuntime.java:267)
at org.xml.sax.helpers.XMLFilterImpl.endElement(Unknown Source)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1257)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:314)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:281)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:196)
at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
at com.sun.xml.xsom.parser.JAXPParser.parse(JAXPParser.java:79)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.parseEntity(NGCCRuntimeEx.java:298)
at com.sun.xml.xsom.impl.parser.ParserContext.parse(ParserContext.java:87)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:147)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:136)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:129)
at com.sun.xml.xsom.parser.XSOMParser.parse(XSOMParser.java:122)
Please let me know if anyone has comment on this.
Also let me know if there any other parser which handles large input files efficiently. -
How to overcome a "System out of memory exception"?
Hi,
As i am running my program , I get (sometimes) an out of memory exception.
I don't know exactly why because I am always doing the same thing so if I get this exception once It should always be so... (of course, as I am trying , no other program is running on my computer! ).
anyway.
I have 3 questions:
1) Do you know how to eliminate this error ?
(I don't mind if the time of execution is longer)
2) I have Win XP, do you think that using a software to build ".exe" files can change the problem ? If so, have you heard about a simple 'one' (I downloaded JET Excelsior, but it seems rather complicated to parametrize)
3) (last but not least) Can someone explain to me WHY there is this type of exception ( I would have thought that when "memory is full", then there is a swap, and the program doesn't stop !
I know there is a lot of questions in one ! ( altough I tried to be short)
ThanksIn answer to your third question, the error occurs when
the JVM runs out of memory, not the OS. Since the OS
controls swapping the fact that the memory space
assigned to the JVM is running low won't cause
swapping to take place. The solution is either a) use
less space by reducing what you have loaded at any
given time or b) increase the amount of memory
available to the JVM. You can user the -Xms, -Xmx and
-Xss switches to increase the amount of memory
available.
Mark -
Hi,
I am developing a windows phone 8 silver light application .
In my app I am displaying images in web browser control one by one , those images are the web links , the problem is after displaying 2 to 3 images I am getting out of memory exception .
I searched for this exception how to over come , everybody are saying memory profiling ,..etc but really I dont know how to release the memory and how to clear the memory .
In some sites they are adding this
<FunctionalCapabilities>
<FunctionalCapability Name="ID_FUNCCAP_EXTEND_MEM"/>
</FunctionalCapabilities>
by doing this am I free from out of memory exception?
Any help ,
Thanks...
Suresh.Mstring HtmlString = "<!DOCTYPE html><html><head><meta name='viewport' content='width=device-width,initial-scale=1.0, user-scalable=yes' /></head>";
HtmlString = HtmlString + "<body>";
HtmlString = HtmlString + "<img src=" + source +" />";
HtmlString = HtmlString + "</body></html>";
innerpagebrowser.NavigateToString(HtmlString);
that image source is the web link for example www.sss.com/files/xxx/123.jpg .
Note this link is not real this is sample and image is of size 2071X3097
Suresh.M -
Large Bitmaps create out of memory exception
Hello,
I try to generate a "BufferedImage" from a Windows Bitmap file ( xxxx.BMP ) .
I can read and generate relatively images from relatively small files (e.g. 852x626 pixels works fine),
but if it comes to larger images, I get an out of memory exception.
Has anybody an idea how to convince Java to read also large BMP image files.
If I create an awt "Image" even large images (eg 1200x5000 pixels are generated).
But unfortunately I have found no way to convert an "Image" to a "BufferedImage" and
only "BufferedImage" offers all the processing methods needed.
This is the code snippet I wrote:
------------ start of code snippet -----------------------------------------------------
try {
DataBufferInt dbBMPInt = new DataBufferInt(nwidth*nheight);
System.out.println("DataBufferInt = "+dbBMPInt);
int [] bitMasks = new int[3];
bitMasks[0] = (int)0xff<<16;
bitMasks[1] = (int)0xff<<8;
bitMasks[2] = (int)0xff;
SinglePixelPackedSampleModel spSM = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,nwidth,nheight,bitMasks);
System.out.println("SinglePixelPackedSampleModel = "+spSM);
WritableRaster bmpRaster = WritableRaster.createWritableRaster((SampleModel) spSM, (DataBuffer) dbBMPInt, new Point(0,0));
System.out.println("WritableRaster = "+bmpRaster);
bmpImage = new BufferedImage(nwidth,nheight,BufferedImage.TYPE_3BYTE_BGR);
System.out.println("BufferedImage = "+bmpImage);
bmpImage.setData(bmpRaster);
catch (Exception exCrBm)
{ /* 001 start catch */
exCrBm.printStackTrace ();
} /* 001 end catch */
----------------------------------------------- end of code snippet --------------------
and this is the generated output.
File type is :BM
Size of file is :1600110
Size of bitmapinfoheader is :40
Width is :852
Height is :626
Planes is :1
BitCount is :24
Compression is :0
SizeImage is :1600056
DataBufferInt = java.awt.image.DataBufferInt@1774b9b
SinglePixelPackedSampleModel = java.awt.image.SinglePixelPackedSampleModel@8080b54
WritableRaster = IntegerInterleavedRaster: width = 852 height = 626 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
BufferedImage = BufferedImage@b9e45a: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@3ef810 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 852 height = 626 #numDataElements 3 dataOff[0] = 2
Any help appreciated
Regards
WolfgangIncrease your maximum heap memory size.
Se -Xmx parameter of java.exe
Have a nice programming day,
Jos�. -
Hi All,
I am using Weblogic server 10.3.2 . when 3 to 5 people hitting server after some time it is giving out of memory Exception ,even i assigned memory parameters maxPermSize:1024 then also i am getting same error.
Application developed using Jdeveloper11g.
Can you please help me figure out the problem.
Thanks and Regards
Sreedhartake a heap dump and use Eclipse MAT to examine the content of the heap
Only if you understand the kind of objects which fill your heap you can solve your problem.
If you use JRockit you can enable oomdiagnostics, basically a post mortem heap dump at the moment the OOM error occurred.
Often it is sufficient to look at the code you are executing: do you have for loops who instantiate objects and put them into a Collection? -
Oracle.jdbc.driver.T4CPreparedStatement causing out of memory exception
I am using oracle spatial 11.2.0.3 g.
I am getting out of memory exception on a process.
I analyzed the heap dump using OOMemory analyzer and figured out oracle.jdbc.driver.T4CPreparedStatement keeping 73% of the heap space.
Is oracle expanding the SPARQL queries in java side or keeping the results in cache.
How to solve it ?Hi,
We will need a re-producible test case (preferably small) to figure out why you are getting out of memory. You can send it to Oracle Support or email me at alan dot wu at oracle dot com.
Jena Adapter does not cache SPARQL query results on the Java side. The T4CPreparedStatement is not even in Jena Adapter's
code path or RDF's code path.
Thanks,
Zhe Wu
Maybe you are looking for
-
How to an on screen dialogue box?
How to an on screen dialogue box?
-
Mapping error for larger messages
HI, My senario is File to File with some conditions ( Conditions are written in UDF ) When i am executing the payload with small size mapping executes correctly . But when i am executing with larger payload Mapping executes but not taking any conditi
-
Security Code Invalid even though it's correct
I recently bought an iphone 4S and entered my credit card info after my purchase and all was fine until about 10:00 the night before last when my phone said my security code was invalid. I later got a call from visa fraud protection services (due to
-
Delta upload not taking place properly
Hello Everyone, I am trying to load data from R/3 to BW. My data target is ODS. For the first infopkg i m doing "initialize delta update". Now i am making changes in particular field in R/3-say i am changing the name of the proj from ABC TO XYZ. Now
-
I am going to be writing a custom report for my b2b messages and was looking at the b2b.B2B_INSTANCEMESSAGE table to build my reports off of. However, I notice that this table is cleared out every day or two. Is there a better table that I could buil