Help! where memory leak exist??
I am new to java, and I wrote this web spider.But the programme is out of memory after downloading about 350 pages.It should download much more pages in theory.Is there memory leak?where?
I have been working on this for several days,but still not find out.Please help me!
package search;
import java.net.*;
import java.io.*;
import java.util.regex.*;
import file.FileOP;
public class SearchOneWeb extends Thread {
private String webName;//host name
private MutexList urlQueue;//MutexList is thread safe class I wrote
public SearchOneWeb(String webName, MutexList urlQueue) {
this.webName = removewww(webName);
this.urlQueue = urlQueue;
urlQueue.add("http://" + webName + "/");
start();
public SearchOneWeb(SearchOneWeb sow) {
this.webName = sow.webName;
this.urlQueue = sow.urlQueue;
start();
public void run(){
try {
search();
} catch (Exception e) {
e.printStackTrace();
* remove www
* @param url
private static String removewww(String url) {
if(url != null) {
int index = url.indexOf("www.");
if (index != -1)
return url.substring(0, index) + url.substring(index + 4);
else
return url;
else
return null;
* make URL object
* @param url
private static URL makeURL(String url) {
if(url == null)
return null;
//only deal with HTTP
if (!url.toLowerCase().startsWith("http://"))
return null;
URL verifiedUrl = null;
try {
verifiedUrl = new URL(url);
if(verifiedUrl.getPath() == null)
verifiedUrl = new URL(verifiedUrl.toString() + "/");
} catch (Exception e) {
return null;
return verifiedUrl;
* test if this url belong to this host
* @param url
private boolean isInHost(URL url) {
boolean result = false;
if(url != null) {
String host = url.getHost().toLowerCase();
if(host.indexOf(webName) != -1)
result = true;
return result;
* down load web page
* @param url
* @return
private String downloadPage(URL url) {
String sURL = url.toString();
String pageContent = null;
try {
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
StringBuffer pageBuffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
pageBuffer.append(line).append('\n');
pageContent = pageBuffer.toString();
reader.close();
con.disconnect();
} catch(IOException e) {
System.out.println("error: can't connect to " + sURL);
return pageContent;
* write file
* @param url
* @param content
private void writeFile(String url, String content, String charSet) {
try {
FileOP.write(url, content, charSet);
} catch (IOException e) {
e.printStackTrace();
System.out.println("can't write file " + url);
* retrive links from page content
* @param pageUrl
* @param pageContents
private void retrieveLinks(URL pageUrl, String pageContents) {
//use regular expression to find links
Pattern pattern = Pattern.compile("<a\\s+href\\s*=\\s*[\"|']?(.*?)['|\"|>]", Pattern.CASE_INSENSITIVE);
Matcher m = pattern.matcher(pageContents);
int index1 = 0;
int index2 = 0;
String link = null;
String path = null;
String dir = null;
URL url = null;
while (m.find()) {
link = m.group(1).trim();
if (link.length() == 0)
continue;
if (link.charAt(0) == '#')
continue;
if (link.indexOf("mailto:") != -1)
continue;
if (link.toLowerCase().indexOf("javascript") != -1)
continue;
if (link.indexOf("://") == -1) {
if (link.charAt(0) == '/') {
link = "http://" + webName + link;
} else {
path = pageUrl.getPath();
dir = path.substring(0, path.lastIndexOf('/') + 1);
link = "http://" + webName + '/' + dir + link;
} else {
if (!link.startsWith("http"))
continue;
else {
index1 = link.indexOf('/', 7);
if (index1 == -1)
link = link + '/';
index2 = link.indexOf('#');
if (index2 != -1) {
link = link.substring(0, index2);
link = removewww(link);
url = makeURL(link);
if (url == null)
continue;
if (!isInHost(url))
continue;
if (urlQueue.contains(link))
continue;
urlQueue.add(link);
public void search() throws Exception {
if (urlQueue == null) {
System.out.println("urlQueue is null!");
return ;
String sURL = null;
URL url = null;
String pageContents = null;
while (urlQueue.size() > 0) {
// Get URL at bottom of the list.
sURL = urlQueue.getHead();
url = makeURL(sURL);
if (url == null)
continue;
pageContents = downloadPage(url);
if (pageContents != null && pageContents.length() > 0) {
writeFile(url.toString(), pageContents, "GBK");
retrieveLinks(url, pageContents);
* for test
* @param args
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
MutexList urlQueue = new MutexList();
SearchOneWeb sow = new SearchOneWeb("news.163.com", urlQueue);
sleep(10000);
SearchOneWeb sow1 = new SearchOneWeb(sow);
SearchOneWeb sow2 = new SearchOneWeb(sow);
}
You said:
I don't delete url from urlQueue,but the point is
that the urlQueue does't consume much memory.
You also said:
The size of urlQueue is tens of thousands when out of
memory,so it consumes several MB memory.
Are these statements both meant to be true at the same time?I meant that urlQueue was not the main reason for out of memory,enen though it consumed several MB memory.It is the strings saving page content that result to out of memory.These strings account for more than 30MB memory when out of memory.The point is why these strings are not GCd. I can not figure it out.
You don't need a queue element after you've processed
it, or even while you're processing it, so just keep
removing and processing the first item in the queue
until it is empty. That's how queues are normally
processed.I modified urlQueue.It keeps removing and processing the first item.But there is no improvement.The strings contaning page content are still not GCd.Why???
Similar Messages
-
Help needed: Memory leak causing system crashing...
Hello guys,
As helped and suggested by Ben and Guenter, I am opening a new post in order to get help from more people here. A little background first...
We are doing LabView DAQ using a cDAQ9714 module (with AI card 9203 and AO card 9265) at a customer site. We run the excutable on a NI PC (PPC-2115) and had a couples of times (3 so far) that the PC just gone freeze (which is back to normal after a rebooting). After monitor the code running on my own PC for 2 days, I noticed there is a memory leak (memory usage increased 6% after one day run). Now the question is, where the leak is???
As a newbee in LabView, I tried to figure it out by myself, but not very sucessful so far. So I think it's probably better to post my code here so you experts can help me with some suggestions. (Ben, I also attached the block diagram in PDF for you) Please forgive me that my code is not written in good manner - I'm not really a trained programmer but more like a self-educated user. I put all the sequence structures in flat as I think this might be easier to read, which makes it quite wide, really wide.
This is the only VI for my program. Basically what I am doing is the following:
1. Initialization of all parameters
2. Read seven 4-20mA current inputs from the 9203 card
3. Process the raw data and calculate the "corrected" values (I used a few formula nodes)
4. Output 7 4-20mA current via 9265 card (then to customer's DCS)
5. Data collection/calculation/outputing are done in a big while loop. I set wait time as 5 secs to save cpu some jucie
6. There is a configuration file I read/save every cycle in case system reboot. Also I do data logging to a file (every 10min by default).
7. Some other small things like local display and stuff.
Again I know my code probably in a mess and hard to read to you guys, but I truely appreciate any comments you provide! Thanks in advance!
Rgds,
Harry
Attachments:
Debug-Harry_0921.vi 379 KB
Debug-Harry_0921 BD.pdf 842 KBWell, I'll at least give you points for neatness. However, that is about it.
I didn't really look through all of your logic but I would highly recommend that you check out the examples for implementing state machines. Your application suffers greatly in that once you start you basically jumped off the cliff. There is no way to alter your flow. Once in the sequence structure you MUST execute every frame. If you use a state machine architecture you can take advantage of shift registers and eliminate most of your local variables. You will also be able to stop execution if necessary such as a user abort or an error. Definitely look at using subVIs. Try to avoid implementing most of your program in formula nodes. You have basically written most of your processing there. While formula nodes are easier for very complex equations most of what you have can easily be done in native LabVIEW code. Also if you create subVIs you can iterate over the data sets. You don't need to duplicate the code for every data set.
I tell this to new folks all the time. Take some time to get comfortable with data flow programming. It is a different paradigm than sequential text based languages but once you learn it it is extremely powerful. All your data flow to control execution rather than relying on the sequence frame structure. A state machine will also help quite a bit.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot -
Help with memory leak using DAQmx & VB6
I'm using DAQmx 8 with VB6 to control an NI 6251 analog input board. The application calls for changing channel configurations as the system is running, thus there are many multiple create task/clear task calls. I've been trying to track a memory leak, so I've created a very simple VB app to help identify the source. I have a loop with the following calls in it:
DAQmxCreateTask
DAQmxAddGlobalChansToTask
DAQmxCfgSampClkTiming
DAQmxStartTask
DAQmxReadAnalogF64
DAQmxClearTask
I see a little over 1Kb leak per loop iteration. If I skip everything except the create task, add channels and clear task, it still shows a leak.
Am I doing something wrong? Should I not be calling CreateTask/ClearTask multiple times?
Thanks for any help.
mfrazerMfrazer,
You definitely don’t want to have CreateTask and subsequently
ClearTask in a loop, nor does it look like you need to for your application.
You only need on task, you just need to change the task, so there is no need to
create multiple tasks. So leave the CreateTask and ClearTask on the outsides of
your loop, and keep everything else on the inside of the loop and make the
changes you need to the task each iteration. Also you are going to want to have
a DAQmxStopTask after your read to make sure the task is stopped and in the
proper state to be reconfigured. I hope that helps.
-GDE -
JVM 1.5.0_11 and libumem -- need stack trace help for memory leak
I'm trying to track down the cause of some memory growth in a java application. In my tests, the java heap appears to remain stable, but the overall memory footprint of the jvm process continues to grow (observed with pmap).
I've run my application with libumem and have found what appears to be the culprit, but the memory allocation is in libjvm.so and I'm looking for ideas what might cause it.
uname -a for my host
SunOS thehost 5.10 Generic_118822-18 sun4u sparc SUNW,Netra-440
Here is the trace from libumem:
1f81c4c0::bufctl_auditADDR BUFADDR TIMESTAMP THREAD
CACHE LASTLOG CONTENTS
1f81c4c0 1f81a470 ac018b4577a0 7
1f43f188 8cda6a4 0
libumem.so.1`umem_cache_alloc+0x210
libumem.so.1`umem_alloc+0x60
libumem.so.1`malloc+0x28
libjvm.so`void*os::malloc+0x28
libjvm.so`void*ResourceObj::operator new+0x38
libjvm.so`ThreadStackTrace::ThreadStackTrace #Nvariant 1+0x34
libjvm.so`void VM_ThreadDump::doit+0xcc
libjvm.so`void VM_Operation::evaluate+0x80
libjvm.so`void VMThread::run+0x6e0
libjvm.so`void*_start+0x208
libc.so.1`_lwp_start
What causes this invocation in the JVM? Is there a known memory leak associated with this?
Thanks in advance for the assistance.More on this issue. The included program will continually allocate memory on the process heap until the JVM cannot allocate memory and it exits with the following exception.
Exception java.lang.OutOfMemoryError: requested 16 bytes for C_Heap: ResourceOBJ. Out of swap space?
import java.lang.StackTraceElement;
import java.lang.Thread;
public class TraceIt {
public static void main(String[] args) {
System.out.println("Starting trace");
int i = 0;
while (true)
if (i%100 == 0) System.out.println(i);
StackTraceElement[] se = Thread.currentThread().getStackTrace();
i++;
} -
Finding Memory Leak in LabVIEW
Hi NG,
we wrote a sort of hugh application in labview that collaborates with our
..NET driven
device framework and a variaty of unmanged c++ libs.
As we are now close to the release we did performance testing and it showed
up that
the app is consuming more memory continously.
We used prefomance counter to check whether the managed objects might not
get garbage collected
but this is done OK, since the handle count stays at a constant level.
We tried to figure out whether one of the c++ libs is causing the problem
but this is not the case either, since
the memory leak exists even if the lib functions are just not being called.
Even labview profiler is not detecting any inconvenient memory consumption
of any of our vis but
windows task manager notices a constant memory consumtion of the executable
(or of labview.exe itselve when running in
dev. environment).
Does anybody know what this might be? Has anybody a clue what other tools we
could use to figure out
where the problem is?
Any help is greatly appreciated.
Thanks in advance, Sebastian Dau!"mfitzsimons" <[email protected]> wrote in message
news:[email protected]..
> Sebastian,
> Memory leaks can be VERY hard to find. I use the divide and conquer
> technique that involves chunking (make into smaller code segments) your
> code into smaller pieces and running the smaller pieces until you find the
> memory leak. It can take weeks to find the source.
you accelerate this process by using the labview profiler.
> The most common is arrays or any data that increases in size as the
> program runs. To fix this you can use a FIFO that allows only so
> many elements to be added before deleting data out of the array. The
> second source is opening references repeatedly and not closing them.
> Look closely at any VI that open anything. Do a search for "Memory
> Leak" on the discussion forum and you will find about 60 postings that may
> help.
> Matt
> If you are using DAQ-MX <a
> href="http://digital.ni.com/public.nsf/allkb/BAF29EE03747EE4B86256E9700541436?OpenDocument"
> target="_blank">http://digital.ni.com/public.nsf/allkb/BAF29EE03747EE4B86256E9700541436?OpenDocument</a>
>
>
arrays and refs have already been checked.
thanks, Sebastian -
Hi! everybody.
We are trying to integrate de SpellUI component in our Flex application and we have a problem when we remove the view where de SpellUI is applied.
We have a test application to profile the memory with a main view that load a component with a textarea where the SpellUI is applied.
The main view can add a child with the component and can remove it. We have a enableSpelling button to enable the word checking and if the spelling is active, the main view can´t remove the componet it is still in memory and it can´t be removed.
¿Are there any way in order to remove the static reference of the SpellUI in the textarea where it is applied?, i think that it is the problem why the component can´t be removed of the memory.
The code: Compiled with Flex 4.0 (Sorry the main app is in a mx and the Component is spark but its works)
SquigglyUIExample.mxml
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.core.UIComponent;
private var texts:ArrayCollection = new ArrayCollection();
private function addDictionary():void{
var text:UIComponent = new TextAreaTest();
text.left = 10;
text.top = 40;
texts.addItem(text);
this.addElement(text);
private function deleteDictionary():void{
for (var i:int = 0; i< texts.length;i++){
var text:UIComponent = texts[i];
this.removeElement(text);
texts.removeItemAt(i);
]]>
</mx:Script>
<mx:Button label="remove" x="235" y="10" click="deleteDictionary()"/>
<mx:Button label="add" x="153" y="10" click="addDictionary()"/>
</mx:Application>
TextAreaTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.adobe.linguistics.spelling.SpellUI;
private function enableFeature():void {
SpellUI.enableSpelling(textArea, "en_US");
private function disableFeature() :void {
SpellUI.disableSpelling(textArea);
]]>
</fx:Script>
<mx:TextArea id="textArea" width="20%" height="20%" fontSize="30" text="Spell cheecking in TextArea " top="10" left="50"/>
<mx:Button id="tt1" label="disable Feature" click="disableFeature()" left="200" top="160"/>
<mx:Button id="tt2" label="enable Feature" click="enableFeature()" left="60" top="160"/>
</s:Group>
Thanks.¿Nobody are worry about memory leaks? or my english is so bad and i explained the problem very bad. .
I only want to confirm with Squiggly developers that this memory leak exists or i´m doing something wrong when the static function SpellUI.enableSpelling is used. do you need more info? ask me please.
I probed with others parts of the Squgglly framework like the TextEditor Example where SpellChecker and HunspellDictionary are created and there is no memory leak, every thing are destroyed properly.
Thanks. -
Best Practices for EJB--memory leak avoidance
I an researching a memory leak. From what I can tell, we do not want to put any instance variables at the class level. This would incur a memory leak when the ejb containers creates the ejb.
I am wondering if there are any more 'best practices' with EJBs that prevent memory leaks. A good site would help me too
RussThank for your reply.
You are right. I was referring to stateless session
beans.
What I was thinking was the following:
1. Making parameters final unless the parameter
r state is changed inside a method.Won't help with memory leaks. There are benefits for an object being immutable, but I don't think that it eliminates the possibility of the object being leaked.
2. All instance variables in stateless session beans
s should be set to null upon ejbPassivate and
ejbRemove operations. The variables should be
populated on ejbCreate and ejbActivate.Optimizing compilers don't need the hint of setting the reference to null. I don't think that helps, but I'm not 100% certain.
3. Before throwing an exception at the session bean
level, clear up all the instance variables by setting
them to null.Shouldn't scope make it clear to the GC that the objects aren't needed? If they're all primitives, how does this help memory leaks?
I am using a profiler to identify the objects still
being held onto once GC, but I was hoping others with
more experience than I would share some of their tips
on how they avoid memory leaks.I don't know where you're getting these tips, but I don't think they're helpful.
Collections and Singletons would be the places where I'd look. If you add a reference to an object that holds onto it in a collection and never lets go, the GC won't reclaim it.
Singletons aren't cleaned up, because their instance is static. Anything the Singleton refers to won't be cleaned up unless the Singleton relinquishes the reference.
Look for things like that. I think they matter more.
% -
Help with Java Memory Leak in URLConnection
Hi everyone,
I can't seem to find the memory leak in the below code, if anyone could help, i would greatly appreciate it. The jist of the code is: I open up a URLConnection to update a ColdFusion page that takes in URL parameters passed in my URL. Then, I get the response. I also check for proxy usage and take that into consideration when making the connection.
I have one class to handle the Connections, Connect.java:
* Connection using Username and Password, as well as boolean option to use Basic Proxy Authentication
public Connect(String pHost, String pPort, String urlString,
String pUsername, String pPassword, boolean useProxy) {
this.pHost = pHost;
this.pPort = pPort;
this.urlString = urlString;
this.pUsername = pUsername;
this.pPassword = pPassword;
this.useProxy = useProxy;
* Get the Input Stream from the Connection given a specific URL
public java.io.InputStream getInputStream(String urlString) {
if (urlString == null) urlString = this.urlString;
exDialog = new ExceptionDialog(new javax.swing.JFrame());
try {
String auth = "";
if (useProxy) {
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", pHost);
System.getProperties().put("proxyPort", pPort);
String authString = "";
if (pUsername != null && pUsername != "") authString = pUsername + ":";
else authString = "username:";
if (pPassword != null && pPassword != "") authString = authString + pPassword;
else authString = authString + "password";
auth = "Basic " + new sun.misc.BASE64Encoder().encode(authString.getBytes());
java.net.URL url = new java.net.URL(urlString);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection)url.openConnection();
if (useProxy) conn.setRequestProperty("Proxy-Authorization", auth);
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)");
conn.setDoInput( true );
conn.setDoOutput( true );
conn.connect();
return conn.getInputStream();
} catch (java.io.IOException ioe) {
exDialog.showForThrowable(ioe.toString(),ioe);
return null;
}I call the code in Download.java:
Connect conn = new Connect(sm.pHost, sm.pPort, null, sm.pUser, sm.pPass, sm.useProxy);
new BufferedReader(new InputStreamReader(conn.getInputStream(sUpdateURL)));
in.close();For some reason, as I loop through this call, the memory footprint of my program grows through every iteration, eventually resulting in a Java Out of Memory error. I can't track the leak down and it's fairly frustrating. If anyone can help, that would be greatly appreciated. Thanks!One place there might be a memory leak is in the line
exDialog = new ExceptionDialog(new javax.swing.JFrame());Even though the JFrame object goes out of scope when the ExceptionDialog method returns, JFrames stay around until they are closed, even though in this case it isn't even shown on the screen. -
Possible memory leak in JSF � help needed
Hi,
We are developing a JSF application using the following:
SUN JSF 1.1_02-b08
Tomahawk 1.1.3
Tomcat 5.5
Our application includes pages with lists; these lists are held and extracted from backing beans.
We are using these beans in request scope with <t:saveState> tag (to avoid holding the lists in the session all the time).
We tested the application using JProbe and found out that each bean that was used in the saveState was added to the view (to the session) , each time we entered the page , and the bean was not released until the end of the session (instead of only one instance of the backing bean).
After I found this problem, I added the following context params to the web.xml:
com.sun.faces.NUMBER_OF_VIEWS_IN_SESSION = 1 (instead of the default 15)
com.sun.faces.NUMBER_OF_VIEWS_IN_LOGICAL_VIEW_IN_SESSION = 1 (instead of the default 15)
We tested the application again, and now no unnecessary instances of the beans were held in the session (in the view).
BUT , now when we use the browser �Back� button, and returning to a page with a list, when selecting an item from the list, no action is performed (the list in the server side does not exist).
My questions are:
1)What is the meaning (difference) of each of the context param : NUMBER_OF_VIEWS_IN_SESSION , NUMBER_OF_VIEWS_IN_LOGICAL_VIEW_IN_SESSION
2)What are the recommended values for these parameters, to minimize session memory, and to enable the usage of the browser �Back� button.
Thank you all,
Lior.Me too.
Please somebody knows how can we avoid memory leak problems in JSF 1.1 ?
Thansk in advanced -
About Memory Leak in JAVA Any body pls help me
Hi All,
In our application, with JAVA we are using c, c++ native methods also.
The problem is, Eventhough the application is in idle state, the Virtual Memory occupation is getting increased. For 24 hours, 30 MB is increased, while the application is in idle state.
Is there any possiblity, this much memory leak can happen in JAVA. or it is from Native c side..
I would appreciate anybody' s help.Thanks
I am using JProfiler for that. I can observe what kind of objects not getting freed and the size of memory it is taking. and i observed thro JProfiler, that is only 16 kb of memory leak is happening. Can Any body who is well known about JProfiler help me. Can i differentiate the memory leak from JAVA and Native C side using JProfiler.
Any help would be appreciated. -
Huge Memory Leak - Need help.
Hi,
There is a huge memory leak in our application. Because of this there are frequent session timeout. When we analysed the heap dump using Memory Analyser Tool, we got the leak suspects and the problem suspects are as below:
One instance of "org.apache.jasper.compiler.JspRuntimeContext" loaded by "org.apache.catalina.loader.StandardClassLoader @ 0x87ff8098" occupies 161,832,200 (23.30%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Segment[]" loaded by "<system class loader>".
One instance of "org.apache.catalina.tribes.tipis.LazyReplicatedMap" loaded by "org.apache.catalina.loader.StandardClassLoader @ 0x87ff8098" occupies 133,578,920 (19.23%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Segment[]" loaded by "<system class loader>".
185 instances of "org.apache.jasper.runtime.BodyContentImpl", loaded by "org.apache.catalina.loader.StandardClassLoader @ 0x87ff8098" occupy 133,502,776 (19.22%) bytes.
What could be the root cause for this error and how to resolve this?First, in general you not provided enough details to get any help. OS? OS version? Hardware specifics?
Second, are you running custom code? If so, post it so you can get help.
Third, if you're not running custom code, the odds of you having a "huge memory leak" are pretty small. -
So I'm in the debugging and testing phase of my app and using this tool for tracking memory leaks ( https://github.com/mrdoob/Hi-ReS-Stats )
When I launch my app my numbers are
FPS: 61/60
MS: 17
MEM: 3.157
MAX: 3.157
Now immediately my memory starts increasing from 3.157, 3.167, 3.177, 3.187, 3.197 and so on.
Now if I make any nav selection in my app
MEM changes back down to about 3.215
but then it starts its count again 3.215, 3.225, 3.235, 3.445, 3.455
I don't have any loops happening.
Has anyone run in to this ?
I'm almost tempted to force garbage collection every 60 seconds that the app is idle or something. Not the best way to handle this .. I just dont know where the leak is happening.
Any support is appreciated!
Cheers!Hi there - I just had the same query a couple of days ago (http://forums.adobe.com/thread/977174?tstart=30).
I saw the same symptoms on my app so I built a blank app with just the profiler on stage. I've been monitoring it for a few days now and notice that memory does creep up even when the app is left idle (apart from the profiler) - but ... and this is the important bit ... it does periodically get reduced back to the starting point (when the garbage collector kicks in and memory is released).
When I was monitoring my app the time through this cycle could be well over 5 mins.
If you actually use the monitor when putting your app through it's paces you'll see memory being gobbled up more rapidly and hopefully (if you've no leaks) the garbage collection kicking in more regularly and bringing the reported usage back down. -
I've only owned this Macbook for about 4 months now and it has started giving me this save memory leak issue every so often. I am not 100% sure if this is the proper place to post this kind of stuff, but I've tried to uninstall some things that I've added in the last month (which is when it started). No luck.
Can anyone tell what it might be just by looking?
Error Report
Anonymous UUID: 69F44AA1-027D-B2A4-9036-9DF6EBE5D770
Thu Jan 1 22:53:52 2015
*** Panic Report ***
panic(cpu 2 caller 0xffffff8022b79085): "zalloc: zone map exhausted while allocating from zone kalloc.8192, likely due to memory leak in zone kalloc.64 (1112477184 total bytes, 17382449 elements allocated)"@/SourceCache/xnu/xnu-2782.1.97/osfmk/kern/zalloc.c:2521
Backtrace (CPU 2), Frame : Return Address
0xffffff80bbd7bc00 : 0xffffff8022b3a811
0xffffff80bbd7bc80 : 0xffffff8022b79085
0xffffff80bbd7bdb0 : 0xffffff8022b42ef1
0xffffff80bbd7bde0 : 0xffffff8022b22a90
0xffffff80bbd7be10 : 0xffffff8022b3e8b7
0xffffff80bbd7be40 : 0xffffff8022b235a3
0xffffff80bbd7be90 : 0xffffff8022b33e8d
0xffffff80bbd7bf10 : 0xffffff8022c0a142
0xffffff80bbd7bfb0 : 0xffffff8022c3ac66
BSD process name corresponding to current thread: WindowServer
Mac OS version:
14B25
Kernel version:
Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64
Kernel UUID: 89E10306-BC78-3A3B-955C-7C4922577E61
Kernel slide: 0x0000000022800000
Kernel text base: 0xffffff8022a00000
__HIB text base: 0xffffff8022900000
System model name: MacBookPro9,2 (Mac-6F01561E16C75D06)
System uptime in nanoseconds: 182760011229369
vm objects:24524880
vm object hash entri:3801640
VM map entries:5061280
pv_list:19697664
vm pages:64337216
kalloc.16:91921984
kalloc.32:130084416
kalloc.64:1112477184
kalloc.128:9461760
kalloc.256:7639040
kalloc.512:49831936
kalloc.1024:4407296
kalloc.2048:3215360
kalloc.4096:10162176
kalloc.8192:6324224
mem_obj_control:1522048
ipc ports:3965600
threads:1624696
vnodes:15977280
namecache:5540640
HFS node:21820528
HFS fork:7712768
cluster_write:2037072
decmpfs_cnode:1866816
buf.8192:10346496
ubc_info zone:5286864
vnode pager structur:2395720
compressor_pager:2375680
compressor_segment:4024080
Kernel Stacks:3604480
PageTables:155758592
Kalloc.Large:19787177
Backtrace suspected of leaking: (outstanding bytes: 21440)
0xffffff8022b79486
0xffffff8022b42ef1
0xffffff802305e513
0xffffff802307ada1
0xffffff80230b665e
0xffffff802305d01e
0xffffff802305d1e7
0xffffff80230b05c5
0xffffff80230b6dd0
0xffffff7fa35a3cc4
0xffffff7fa359eb0c
Kernel Extensions in backtrace:
com.razer.common.razerhid(10.57)[91AF82D9-68E7-3D2F-9D29-31113DBA21EE]@0xffffff 7fa3599000->0xffffff7fa35b1fff
dependency: com.apple.iokit.IOUSBFamily(705.4.14)[E15E9DC8-410F-3612-8371-E5FECD939E0D]@0xf fffff7fa3316000
dependency: com.apple.iokit.IOHIDFamily(2.0.0)[917971EF-5947-3DF5-BB9F-D353D05C0484]@0xffff ff7fa3431000
dependency: com.apple.iokit.IOUSBHIDDriver(705.4.0)[2CB055E6-0535-39A2-A393-F8FECDA6863B]@0 xffffff7fa34bb000
dependency: com.apple.driver.IOBluetoothHIDDriver(4.3.1f2)[12CE576E-DC6B-3F99-A180-909E93DA F5C3]@0xffffff7fa3585000
last loaded kext at 168541610122784: com.apple.driver.AppleUSBCDC 4.2.2b5 (addr 0xffffff7fa53cd000, size 20480)
last unloaded kext at 168658428597842: com.apple.driver.AppleUSBCDC 4.2.2b5 (addr 0xffffff7fa53cd000, size 16384)
loaded kexts:
org.virtualbox.kext.VBoxNetAdp 4.3.18
org.virtualbox.kext.VBoxNetFlt 4.3.18
org.virtualbox.kext.VBoxUSB 4.3.18
org.virtualbox.kext.VBoxDrv 4.3.18
com.razer.common.razerhid 10.57
com.apple.filesystems.smbfs 3.0.0
com.apple.driver.AudioAUUC 1.70
com.apple.filesystems.autofs 3.0
com.apple.iokit.IOBluetoothSerialManager 4.3.1f2
com.apple.driver.AGPM 100.14.37
com.apple.driver.X86PlatformShim 1.0.0
com.apple.driver.AppleOSXWatchdog 1
com.apple.driver.AppleMikeyHIDDriver 124
com.apple.driver.AppleHDA 267.0
com.apple.driver.AppleMikeyDriver 267.0
com.apple.iokit.IOUserEthernet 1.0.1
com.apple.Dont_Steal_Mac_OS_X 7.0.0
com.apple.driver.AppleSMCPDRC 1.0.0
com.apple.driver.AppleSMCLMU 2.0.4d1
com.apple.driver.AppleHWAccess 1
com.apple.driver.AppleHV 1
com.apple.driver.AppleUpstreamUserClient 3.6.1
com.apple.driver.AppleThunderboltIP 2.0.2
com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport 4.3.1f2
com.apple.driver.AppleBacklight 170.4.12
com.apple.driver.AppleMCCSControl 1.2.10
com.apple.driver.AppleLPC 1.7.3
com.apple.driver.AppleIntelHD4000Graphics 10.0.0
com.apple.driver.AppleIntelFramebufferCapri 10.0.0
com.apple.driver.SMCMotionSensor 3.0.4d1
com.apple.driver.AppleUSBTCButtons 240.2
com.apple.driver.AppleUSBTCKeyboard 240.2
com.apple.driver.AppleIRController 327.5
com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0d1
com.apple.BootCache 35
com.apple.iokit.SCSITaskUserClient 3.7.0
com.apple.driver.XsanFilter 404
com.apple.iokit.IOAHCIBlockStorage 2.6.5
com.apple.driver.AirPort.Brcm4360 901.19.10
com.apple.driver.AppleUSBHub 705.4.1
com.apple.driver.AppleSDXC 1.6.5
com.apple.iokit.AppleBCM5701Ethernet 10.1.2b3
com.apple.driver.AppleFWOHCI 5.5.2
com.apple.driver.AppleAHCIPort 3.0.7
com.apple.driver.AppleUSBXHCI 705.4.14
com.apple.driver.AppleUSBEHCI 705.4.14
com.apple.driver.AppleSmartBatteryManager 161.0.0
com.apple.driver.AppleACPIButtons 3.1
com.apple.driver.AppleRTC 2.0
com.apple.driver.AppleHPET 1.8
com.apple.driver.AppleSMBIOS 2.1
com.apple.driver.AppleACPIEC 3.1
com.apple.driver.AppleAPIC 1.7
com.apple.driver.AppleIntelCPUPowerManagementClient 218.0.0
com.apple.nke.applicationfirewall 161
com.apple.security.quarantine 3
com.apple.security.TMSafetyNet 8
com.apple.driver.AppleIntelCPUPowerManagement 218.0.0
com.apple.kext.triggers 1.0
com.apple.iokit.IOSerialFamily 11
com.apple.driver.DspFuncLib 267.0
com.apple.kext.OSvKernDSPLib 1.15
com.apple.iokit.IOAudioFamily 200.6
com.apple.vecLib.kext 1.2.0
com.apple.driver.AppleSMBusPCI 1.0.12d1
com.apple.iokit.IOFireWireIP 2.2.6
com.apple.driver.X86PlatformPlugin 1.0.0
com.apple.driver.AppleHDAController 267.0
com.apple.iokit.IOHDAFamily 267.0
com.apple.iokit.IOBluetoothHostControllerUSBTransport 4.3.1f2
com.apple.driver.AppleBacklightExpert 1.1.0
com.apple.driver.AppleSMBusController 1.0.13d1
com.apple.iokit.IOUSBUserClient 705.4.0
com.apple.driver.IOPlatformPluginFamily 5.8.0d49
com.apple.iokit.IOSurface 97
com.apple.iokit.IONDRVSupport 2.4.1
com.apple.iokit.IOAcceleratorFamily2 156.4
com.apple.AppleGraphicsDeviceControl 3.7.21
com.apple.iokit.IOGraphicsFamily 2.4.1
com.apple.driver.AppleSMC 3.1.9
com.apple.driver.IOBluetoothHIDDriver 4.3.1f2
com.apple.iokit.IOBluetoothFamily 4.3.1f2
com.apple.driver.AppleUSBMultitouch 245.2
com.apple.iokit.IOUSBHIDDriver 705.4.0
com.apple.driver.AppleUSBMergeNub 705.4.0
com.apple.driver.AppleUSBComposite 705.4.9
com.apple.driver.CoreStorage 471
com.apple.iokit.IOSCSIMultimediaCommandsDevice 3.7.0
com.apple.iokit.IOBDStorageFamily 1.7
com.apple.iokit.IODVDStorageFamily 1.7.1
com.apple.iokit.IOCDStorageFamily 1.7.1
com.apple.driver.AppleThunderboltDPInAdapter 4.0.6
com.apple.driver.AppleThunderboltDPAdapterFamily 4.0.6
com.apple.driver.AppleThunderboltPCIDownAdapter 2.0.2
com.apple.iokit.IOAHCISerialATAPI 2.6.1
com.apple.iokit.IOSCSIArchitectureModelFamily 3.7.0
com.apple.driver.AppleThunderboltNHI 3.1.7
com.apple.iokit.IOThunderboltFamily 4.2.1
com.apple.iokit.IO80211Family 700.52
com.apple.iokit.IOEthernetAVBController 1.0.3b3
com.apple.driver.mDNSOffloadUserClient 1.0.1b8
com.apple.iokit.IONetworkingFamily 3.2
com.apple.iokit.IOFireWireFamily 4.5.6
com.apple.iokit.IOAHCIFamily 2.7.0
com.apple.iokit.IOUSBFamily 705.4.14
com.apple.driver.AppleEFINVRAM 2.0
com.apple.driver.AppleEFIRuntime 2.0
com.apple.iokit.IOHIDFamily 2.0.0
com.apple.iokit.IOSMBusFamily 1.1
com.apple.security.sandbox 300.0
com.apple.kext.AppleMatch 1.0.0d1
com.apple.driver.AppleKeyStore 2
com.apple.driver.AppleMobileFileIntegrity 1.0.5
com.apple.driver.AppleCredentialManager 1.0
com.apple.driver.DiskImages 389.1
com.apple.iokit.IOStorageFamily 2.0
com.apple.iokit.IOReportFamily 31
com.apple.driver.AppleFDEKeyStore 28.30
com.apple.driver.AppleACPIPlatform 3.1
com.apple.iokit.IOPCIFamily 2.9
com.apple.iokit.IOACPIFamily 1.4
com.apple.kec.Libm 1
com.apple.kec.pthread 1
com.apple.kec.corecrypto 1.0
Model: MacBookPro9,2, BootROM MBP91.00D3.B09, 2 processors, Intel Core i5, 2.5 GHz, 4 GB, SMC 2.2f44
Graphics: Intel HD Graphics 4000, Intel HD Graphics 4000, Built-In
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343235533641465236412D50422020
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343235533641465236412D50422020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xF5), Broadcom BCM43xx 1.0 (7.15.124.12.10)
Bluetooth: Version 4.3.1f2 15015, 3 services, 19 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en1
Serial ATA Device: Samsung SSD 840 EVO 250GB, 250.06 GB
Serial ATA Device: HL-DT-ST DVDRW GS41N
USB Device: Hub
USB Device: Hub
USB Device: Razer DeathStalker
USB Device: Razer DeathAdder
USB Device: Hub
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
USB Device: IR Receiver
USB Device: Hub
USB Device: FaceTime HD Camera (Built-in)
Thunderbolt Bus: MacBook Pro, Apple Inc., 25.1I'm sorry to have conveyed that impression. I do very much like EtreCheck, but it is completely misused by too many people who seem to think it's the answer to all problems. If is excellent for what it does. I helped beta test it for the developer. But it's a tool best used when a helper specifically asks for it when it is needed. That isn't for kernel panics. It may well be that some software can cause the panic, but the panic itself is generally in hardware. You can see that in the first few lines of the report. I urge you to learn more about them:
Mac OS X- How to log a kernel panic
OS X- About kernel panics
Technical Note TN2063- Understanding and Debugging Kernel Panics
Tutorial - Avoiding and eliminating Kernel panic
What's a "kernel panic"? (Mac OS X)
OSXFAQ - Troubleshooting Kernel Panics
Visit The XLab FAQs and read the FAQ on diagnosing kernel panics.
You will find a wealth of information about panics in the above references. There are many panic reports that simply don't give us any clues as to their root cause. They can be frustrating to deal with. But when someone is having a kernel panic EtreCheck is simply not the tool you whip out first or even second.
Good luck learning and a Happy New Year. -
Memory leak when transferring pdf...help needed
Dear All,
I'm a newbie in developing java app. I'm making a web based application in reporting using JSP. java 1.6.02, jasper report 204, i-report 2.0.0
Client : OS : Win xp, memory 512MB
Server : Tomcat 6.0
DB Server : SQL Server 2005
OS Server : Windows Server 2003, memory 1GB
Report spec : .pdf based, with up to 1million record
Here's the code :
String query;
try {
String filereport = request.getRealPath("division/accounting/template/POReport.jrxml");
InputStream input = new FileInputStream(filereport);
Class.forName(odbcDriver);
Connection conn = DriverManager.getConnection(odbcURL,username,passwd);
ResultSet rset = null;
CallableStatement cs = null;
query = "{ call sp_tpo_list }";
cs = conn.prepareCall(query);
rset = cs.executeQuery();
JRDataSource dataSource = new JRResultSetDataSource(rset);
JasperDesign design = JRXmlLoader.load(input);
JasperReport report = JasperCompileManager.compileReport(design);
JasperPrint print = JasperFillManager.fillReport(report, null, dataSource);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(print, baos);
response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream sos;
sos = response.getOutputStream();
baos.writeTo(sos);
sos.flush();
rset.close();
cs.close();
conn.close();
sos.close();
baos.close();
input.close();
catch (FileNotFoundException fe) {}
catch (JRException jre) {}
catch (ClassNotFoundException cnfe) {}
catch (SQLException sqle) {}
catch (IOException ioe) {}I've already increase heap memory in Tomcat Manager -Xms 64Mb -Xmx 512Mb.
But when i test with 1million record, out of heap memory error is coming out.
When i test with 500.000 record, it work out, but only when 1 client access. More than 1 client, out of heap memory error generated by the system.
How can this happen? How can i detect memory leaks occured in the program?
And pls let me know if you see something is missing in the code above.
Thank youI dont think you have a memory leak. I think the problem is the xml file is 1000000 records long and takes up too much memory. Even if you find a way to increase memory size, you are loading down the server too much for other people's applications to run. I suggest instead reading up on xml and learning how to read in only a few records at a time, processing it, and getting the next set of records to process. There are two methods to parse an xml file using an xml parser, one is to parse it all and put it in memory, the other is to process one record at a time (an xml book explains it better).
However, I question why you have reports that are 1000000 records long. end-users cannot effectively use such records (you cant scroll through 1000000 records). I suggest finding a way to greatly decrease the number of records in each file such as by providing just the records a particular user needs to do his job and not all records. For instance, put a textfield on his screen to let him only fetch records within a certain date range.
Lastly, I suggest putting your code in a try/catch/finally block where the finally block actually closes the objects. Example:
finally{
if(conn!=null)
conn.close();
} -
Memory leak problem need help!!
public void query(String firstName, String lastName, String citizenId) throws Exception{
this.eimFirstName = firstName;
this.eimLastName = lastName;
this.eimCitizenId = citizenId;
String searchstr = "(([First Name] =\""+firstName+"\" AND [Last Name]=\""+lastName+"\" )OR [Social Security Number]=\""+citizenId+"\") AND [Status]=\"Prospect\""; // = (([First Name] = 'firstName' AND [Last Name] = 'lastName') OR [Citizen Id] = 'citizenId') AND ([Status]='Prospect')
contactWrapper=null; // set to null
contactWrapper=new BusCompWrapper();//instantiate
contactWrapper.query(siebelWrapper, "Contact", "Contact", searchstr, queryFieldList);//leaks here
}if i comment out the last line , the memory leak won't happen.
correct me if i'm wrong, i think that i need to free the reference of contactWrapper in order to avoid memory leak? but how do i do that? i set it to null but why still i have the leak
thanks guysthis may help
public class BusCompWrapper
private List fields;
private int buscompstatus;
private int position=0;
private com.siebel.data.SiebelBusComp oBusComp;
private com.siebel.data.SiebelBusObject oBusObj;
Gets next record from Business Component
@return Iterator of values in String
@return empty Iterator if no more record to read
public Iterator getNextRecord() throws BoaException
try{
ArrayList al = new ArrayList();
if (position==0){
if (!oBusComp.firstRecord()){
return null;
}else{
if (!oBusComp.nextRecord()){//no more record left, return empty enumeration
return null;
position++;
Iterator it = fields.iterator();
while (it.hasNext()){
String next = (String)it.next();
oBusComp.activateField(next);
String s = oBusComp.getFieldValue(next);
al.add(s);
return al.iterator();
}catch (SiebelException e){
throw new BoaException(e,new String[]{ExceptionConstants.ERROR_GETTING_NEXT_RECORD_IN_BUSINESS_COMP,"\n"+e.getErrorMessage()},2);
public void query(SiebelWrapper siebelWrapper, String busobjname, String buscompname, String querystr,List fields) throws BoaException
try{
oBusObj = siebelWrapper.getSiebelDataBean().getBusObject(busobjname);
oBusComp = oBusObj.getBusComp(buscompname);
Iterator it=fields.iterator();
while(it.hasNext()){
oBusComp.activateField((String)it.next());
oBusComp.setViewMode(3);
oBusComp.clearToQuery();
oBusComp.setSearchExpr(querystr);
oBusComp.executeQuery(true);
this.fields = fields;
position=0;
}catch(SiebelException e){
e.printStackTrace();
throw new BoaException(e,new String[]{ExceptionConstants.ERROR_QUERYING_BUSINESS_COMP,"\n"+e.getErrorMessage()},2);
public class ContactSiebelWrapper
private String
currentRowId,
currentFirstName,
currentLastName,
currentBirthDate,
currentCitizenId;
private SiebelWrapper siebelWrapper;
private ArrayList currentUpdate;
private String eimFirstName;
private String eimLastName;
private String eimCitizenId;
private ArrayList phoneList;
private ArrayList addressList;
private BusCompWrapper contactWrapper;
private static List queryFieldList=Arrays.asList(new String[]{"Id","First Name","Last Name","Social Security Number","Birth Date","Status","Integration Id","Party UId"});
private static List phoneFieldList=Arrays.asList(new String[]{"ACU Telephone Type","ACU Telephone Number","ACU Telephone Extension"});
private static List addressFieldList=Arrays.asList(new String[]{"Street Address","Street Address 2","ACU Street Address 3","City","Postal Code"});
/**FileLogger for event logging*/
private FileLogger logger;
/**Date format for parsing date to Date object*/
private String siebelDateFormat;
Constructs ContactSiebelWrapper from specified SiebelWrapper and FileLogger objects
public ContactSiebelWrapper(SiebelWrapper param,FileLogger logger,String siebelDateFormat)
this.logger=logger;
siebelWrapper = param;
currentUpdate = new ArrayList();
phoneList = new ArrayList();
this.siebelDateFormat=siebelDateFormat;
Advances to the next record in Business component.
@return true if there is next record, false otherwise
public boolean advanceRecord() {
try {
Iterator retval = contactWrapper.getNextRecord();
if (retval==null){
/*contactWrapper=null;
phoneList=null;
addressList=null;*/
return false;
currentRowId = (String) retval.next();
currentFirstName = CommonUtils.iso8859_1ToMS874((String) retval.next());
currentLastName = CommonUtils.iso8859_1ToMS874((String) retval.next());
currentCitizenId = (String) retval.next();
currentBirthDate = (String) retval.next();
getPhoneList();
getAddressList();
return true;
} catch (Throwable e) {
logger.logLine("ERROR while advancing to next record");
e.printStackTrace();
return false;
public void query(String firstName, String lastName, String citizenId) throws Exception{
this.eimFirstName = firstName;
this.eimLastName = lastName;
this.eimCitizenId = citizenId;
String searchstr = "(([First Name] =\""+firstName+"\" AND [Last Name]=\""+lastName+"\" )OR [Social Security Number]=\""+citizenId+"\") AND [Status]=\"Prospect\""; // = (([First Name] = 'firstName' AND [Last Name] = 'lastName') OR [Citizen Id] = 'citizenId') AND ([Status]='Prospect')
contactWrapper=new BusCompWrapper();
contactWrapper.query(siebelWrapper, "Contact", "Contact", searchstr, queryFieldList);
}
Maybe you are looking for
-
Integration with Adobe Photoshop Elements 4
I would like to migrate to Adobe Photoshop Elements 4 for Mac and would like to know how it will integrate with iPhoto. My photos are stored in iPhoto, could I edit them using PE4? How should I generate slideshows? Do I use PE4 or iPhoto? Could I imp
-
Why have I made a further payment?
I've been charged today for a 3 month subscription which I'm extremely happy about because I'm pretty sure I didn't do it. Other questions: Why can I not have Live Chat.. only for "premium"users. So you can charge more, for correcting a fault!? XD I
-
Hi, After upgrading to iOS7, I was asked by the system to set an passcode. When i try to swipe from the notification area, it navigates me to the passcode lock screen which is expected but the same behaviour is not shown for a call - when i swipe fro
-
Edit Cluster Start-stop- and Monitor-Scripts via Bash?
Hi, is there a way to edit (and sync!) the Cluster-Scripts via CLI? Regards Bernd
-
Shrinking document for footers
I am placing footers in my document. I have a saved setting for a right page footer and a different saved setting for a left page footer. (The only thing that changes between these footers is the placement of the page number, which is always on th