Datagrid column in module causing memory leak
Hi All
I'm having trouble with a DataGrid column preventing a module from being release properly. I can't imagine this is the intended behaviour.
Using this simple test case, a WindowedApplication and an mx:Module I wonder if anyone else can reproduce this problem. The issue goes away if you simply comment out the GridColumn Instance.
Can anyone offer any advice?
Many thanks
James
DataGridTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.core.IVisualElement;
import mx.events.ModuleEvent;
import mx.modules.IModuleInfo;
import mx.modules.ModuleManager;
private var assetModule:IModuleInfo;
protected function load_clickHandler(event:MouseEvent):void
assetModule = ModuleManager.getModule('DataGridTestModule.swf');
assetModule.addEventListener("ready", getModuleInstance);
assetModule.load();
public function getModuleInstance(event:ModuleEvent):void
var sm:DisplayObject = assetModule.factory.create() as DisplayObject;
sm.addEventListener("close", closeModule);
contentHolder.addElement(sm as IVisualElement);
private function closeModule(event:Event):void
event.target.removeEventListener("close", closeModule);
contentHolder.removeElement(event.target as IVisualElement);
assetModule.unload();
assetModule = null;
]]>
</fx:Script>
<s:VGroup width="100%" height="100%">
<s:HGroup >
<s:Button id="load" label="Load" click="load_clickHandler(event)"/>
</s:HGroup>
<s:BorderContainer id="contentHolder" width="100%" height="100%"/>
</s:VGroup>
</s:WindowedApplication>
DataGridTestModule.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
layout="absolute" xmlns:components="components.*">
<fx:Script>
<![CDATA[
protected function close_clickHandler(event:MouseEvent):void
dispatchEvent(new Event('close', true, false))
]]>
</fx:Script>
<s:BorderContainer id="contacts"
width="100%" height="100%"
backgroundAlpha="0"
borderVisible="false">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Button id="close" label="Close" click="close_clickHandler(event)"/>
<s:DataGrid id="queries" >
<s:columns>
<s:ArrayList>
<s:GridColumn/> <!-- Comment out this GridColumn instance to see the leak disappear -->
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:BorderContainer>
</mx:Module>
OK, So I've done some more testing. Creating the GridColumn in AS during the creationComplete event is a slight improvement. It seems to allow the DataGrid and the Module be GC'd, but it's still leaking memory somewhere. I just can't get my head around the Profiler. Also, it's going to be a massive headache if we have to rewrite our application to create all the GridColumns in AS. Surely this shouldn't be necessary?
New test case below:
DataGridTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import mx.core.IVisualElement;
import mx.events.ModuleEvent;
import mx.modules.IModuleInfo;
import mx.modules.ModuleManager;
import spark.components.gridClasses.GridColumn;
private var assetModule:IModuleInfo;
private var sm:DisplayObject;
protected function load_clickHandler(event:MouseEvent):void
assetModule = ModuleManager.getModule('DataGridTestModule.swf');
assetModule.addEventListener("ready", getModuleInstance);
assetModule.load();
public function getModuleInstance(event:ModuleEvent):void
sm = assetModule.factory.create() as DisplayObject;
sm.addEventListener("close", closeModule);
contentHolder.addElement(sm as IVisualElement);
private function closeModule(event:Event):void
event.target.removeEventListener("close", closeModule);
contentHolder.removeElement(event.target as IVisualElement);
assetModule.unload();
assetModule = null;
]]>
</fx:Script>
<s:VGroup width="100%" height="100%">
<s:HGroup >
<s:Button id="load" label="Load" click="load_clickHandler(event)"/>
</s:HGroup>
<s:BorderContainer id="contentHolder" width="100%" height="100%"/>
</s:VGroup>
</s:WindowedApplication>
DataGridTestModule.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="module1_creationCompleteHandler(event)"
layout="absolute" xmlns:components="components.*">
<fx:Script>
<![CDATA[
import flash.utils.setTimeout;
import mx.collections.ArrayList;
import mx.events.FlexEvent;
import spark.components.gridClasses.GridColumn;
[Bindable]
private var _col:ArrayList = new ArrayList();
protected function close_clickHandler(event:MouseEvent):void
dispatchEvent(new Event('close', true, false))
protected function module1_creationCompleteHandler(event:FlexEvent):void
var gc:GridColumn = new GridColumn();
gc.headerText = 'Test Column';
_col.addItem(gc);
]]>
</fx:Script>
<s:BorderContainer width="100%" height="100%">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Button id="close" label="Close" click="close_clickHandler(event)"/>
<s:DataGrid id="queries" columns="{_col}"/>
</s:BorderContainer>
</mx:Module>
Similar Messages
-
JSF: partial page rendering is causing memory leak leading to outofmemory
JDeveloper 10.1.3.2.0
JDK: 1.6.0_06
Operating System: Windows XP.
I test my application for memory leaks. For that purpose, I use jconsole to monitor java heap space. I have an edit page that has two dependent list components. One displays all countries and the other displays cities of the selected country.
I noticed java heap space keeps growing as I change country from country list.
I run garbage collection and memory usage does not go down. If I keep changing the province for 5 minutes, then I hit a java heap space outofmemory exception.
To narrow down the problem, I removed the second city component and the problem still exists.
To narrow it down further, I removed autosubmit attribute from the country component and then memory usage stopped increasing as I change country.
country/city partial page rendering is just an example. I am able to reproduce the same problem on every page where i use partial page rendering. My conclusion is PPR is causing memory leak or at least the autosubmit attribute.
This is really bad. Anyone out there experienced same issue. Any help/advice is highly appreciated !!
Thanks
<af:panelLabelAndMessage
inlineStyle="font-weight:bold;"
label="Country:"
tip=" "
showRequired="true"
for="CountryId">
<af:selectOneChoice id="CountryId"
valuePassThru="true"
value="#{bindings.CountryId.inputValue}"
autoSubmit="true"
inlineStyle="width:221px"
simple="true">
<af:forEach var="item"
items="#{bindings.CountriesListIterator.allRowsInRange}">
<af:selectItem value="#{item.countryId}"
label="#{item.countryName}"/>
</af:forEach>
</af:selectOneChoice>
</af:panelLabelAndMessage>
<af:panelLabelAndMessage
inlineStyle="font-weight:bold;"
label="City:"
tip=" "
showRequired="true"
for="CityId">
<af:selectOneChoice id="CityId"
valuePassThru="true"
value="#{bindings.CityId.inputValue}"
partialTriggers="CountryId"
autoSubmit="true"
inlineStyle="width:221px"
unselectedLabel="--Select City--"
simple="true">
<f:selectItems value="#{backing_CountryCityBean.citiesSelectItems}"/>
</af:selectOneChoice>
</af:panelLabelAndMessage>Samsam,
I haven't seen this problem myself, no.
To clarify - are you seeing this behaviour when running your app in JDeveloper, or when running in an application server? If in JDeveloper, a copuple of suggestions:
* (may not matter, but...) It's not supported to run JDev 10g with JDK 6
* have you tried the [url http://www.oracle.com/technology/pub/articles/masterj2ee/j2ee_wk11.html]memory profiler
Best,
John -
Can Java program cause memory leak?
Can Java program cause memory leak or memory crash? I don't mean any memory overflow related exceptions. I mean something like core dump in UNIX or error reports in Windows XP.
If it can really happen, in what circumstances? I raise such a question because our J2EE based system had really caused memory leak in Windows XP systems, but so far we still fail to troubleshoot the problem.Your code may leak memory. There are many, many, many reasons this could be. All of them represent bugs in your code.
You should get a profiler to identify the problem spots of your code.
You spoke of a memory crash as well. The VM may crash with some bug in the VM, or a bug in native code but that is not relevent to your problem. A memory leak is a problem in your code. -
Calling SetLocalTime in C# causes Memory Leak (WEC7)
Hello,
I use SetLocalTime() in C#. Everything works well if I start explorer.exe and my application. But if I don't start explorer.exe at system start. SetLocalTime() causes memory leak in my application. I call the function frequently every hour.
public static bool SetzeLokalZeit(SYSTEMDATETIME lpSystemTime)
#if DEADLOCKDETECT
using (DdMonitor.Lock(MyTimeLock, "MyTimeLock#1"))
#else
lock (MyTimeLock)
#endif
bool ret = false; // no Success
try
GLB.LogFile.MyWrite("SetLocalTime");
SYSTEMDATETIME loc = new SYSTEMDATETIME();
loc.wYear = lpSystemTime.wYear;
loc.wMonth = lpSystemTime.wMonth;
loc.wDayOfWeek = lpSystemTime.wDayOfWeek;
loc.wDay = lpSystemTime.wDay;
loc.wHour = lpSystemTime.wHour;
loc.wMinute = lpSystemTime.wMinute;
loc.wSecond = lpSystemTime.wSecond;
loc.wMilliseconds = lpSystemTime.wMilliseconds;
ret = SetLocalTime(ref loc);
if (!ret) // no Success
int err = Marshal.GetLastWin32Error();
if (err > 0)
GLB.LogFile.MyWrite("ERROR CODE:" + err.ToString());
else ret = true;
catch (Exception ex)
GLB.LogFile.MyWrite("000023 Exception" + ex.Message);
finally
GLB.LogFile.MyWrite("SetLocalTime Ende");
return ret;
Has someone an idea what's the problem?
Best regards,
AndreasHello,
Here the answers to the questions:
1. Does the SetLocalTime function succeed?
Calling SetLocalTime doesn't cause an exception an the local time is set correctly.
2. Do you still get the memory leak if you remove all other calls?
Yes. I have removed any other code, but I also get the memory leak.
3. Does the memory leak also occur when you do this from native code?
I have not tried it yet. But I will still make it...
[DllImport("coredll.dll")]
private static extern void GetLocalTime(ref SYSTEMDATETIME lpSystemTime);
[DllImport("coredll.dll", SetLastError = true)]
private static extern bool SetLocalTime(ref SYSTEMDATETIME lpSystemTime);
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEMDATETIME
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
public static bool Pub_SetLocalTime(SYSTEMDATETIME lpSystemTime)
lock (MyTimeLock)
bool ret = false; // no Success
try
loc_set.wYear = lpSystemTime.wYear;
loc_set.wMonth = lpSystemTime.wMonth;
loc_set.wDayOfWeek = lpSystemTime.wDayOfWeek;
loc_set.wDay = lpSystemTime.wDay;
loc_set.wHour = lpSystemTime.wHour;
loc_set.wMinute = lpSystemTime.wMinute;
loc_set.wSecond = lpSystemTime.wSecond;
loc_set.wMilliseconds = lpSystemTime.wMilliseconds;
ret = SetLocalTime(ref loc_set);
if (!ret) // no Success
int err = Marshal.GetLastWin32Error();
if (err > 0)
MessageBox.Show("Win32 Error:", err.ToString());
else ret = true;
catch (Exception ex)
MessageBox.Show("SetLocalTime,Exception:", ex.ToString());
finally
return ret;
Best regards,
Andreas -
The Security ID is not valid causes memory leak in Ldap
Hi, all:
We are using the Novell LDAP Provider to allow our server application
be configured in LDAP mode. One of our clients is experiencing a memory
leak and we believe that the problem could be related to a "The Security
ID is not valid" error. When he changes to native Active Directory mode
the memory leak dissapears (he still gets the "Security ID" error, but
all works fine). So, we think that the problem caused by the "Security
ID" error is affecting the Novell Ldap Provider library. He is using a
Windows 2008 R2 platform.
My question is: Do you know if these kind of errors are properly
handled so that resources are released?
We are using the 2.1.10.1 version of the library.
Many thanks for you help,
Luis
luixrodix
luixrodix's Profile: http://forums.novell.com/member.php?userid=107647
View this thread: http://forums.novell.com/showthread.php?t=435894ab;2091346 Wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Have the exact error message? Is it safe to assume you are querying
> MAD
> and not eDirectory? I make that assumption because you mentioned
> SIDs.
>
> Good luck.
>
> Yes the message is: "The Security ID structure is invalid". It is the
> error 1337 of Windows and cannot be fixed manually since SIDs cannot be
> modified manually.
>
>
> When the client has configured our tool as Active Directory via LDAP
> (using the Novell Ldap library) the error is not logged anywhere (that's
> another reason for thinking that the library is not handling the error
> correctly) and the application has memory leaks everytime the AD server
> is queried, but when they use the same Active Directory but in a pure AD
> configuration (using System.DirectoryServices and Windows API directly)
> the error is logged and the memory of the application remains stable.
>
> I asked the client to fix the Security ID problem, trying to find the
> user(s) whose SID are wrong and re-creating them, but if the Novell.Ldap
> library is not handling this error correctly the potential problem is
> still there.
>
>
>
>
>
> On 03/30/2011 08:36 AM, luixrodix wrote:
> >
> > I mean, everytime a query is sent to the LDAP server an Invalid SID
> is
> > reported, and some resources are not released. We think that the
> problem
> > could be in the LDAP Novell library.
> >
> >
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.15 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - 'Enigmail: A simple interface for
> OpenPGP email security' (http://enigmail.mozdev.org/)
>
> iQIcBAEBAgAGBQJNk2bcAAoJEF+XTK08PnB5K1oP/RB5AUOUtXi13jS/3bSG0wVC
> uErEfdqBj6R7yliZ8oqkLApQXzEomMwmSRwa4K6v+Rj1MDFBW+ nBFTOv4aHVgq53
> ANslfM0inboZIxuQxBEhB/5HD062s4yGHTgL81LgeKdYyZvx0np6zmgDOVA/Ogx5
> GS0nQfAhUZ+tAlgrhzRj3FB9WaamSQsdmEbXCTLjIrhy2FjH14 RidAmY0civvAsw
> 5EoAlPe56JzQWhdzyIMhodVB2lIa2b+ttoKY7+Q35PsW2KJ3zl +O2MgHBdBtGUOQ
> DekIR3h5kOjsRGAia8Td1eqSjziNB04fBcjR++B1vLuzE7YSGR mfRVAofOdjtlsR
> lQ7sRX5Wg9cKN0KniMmvgrKaMqYcnl3wGgvhbVDA+vgriOxnRt PRssrTckrRaOcU
> KvE3efwvgbdWeRNdfVAwU2qMPrsEA051XBtRKCclv5Ebi6AgwZ uuT3rYRm2Ycusy
> TebrcX+YkiCZE+GYfULzN2KDUoxCbB85xBGwsg9Iz2/nTt6mkHT0+KqNM713uNJX
> OqtJJP1fvfw6JMeQW5rS0VrTl2yGncJHf+cvrp0cXx8l+CJkB3 X7phZ5N0c1ttTc
> 9cPCT+WuC7lCn4QviC8QlmZUYfbGDZmYbxm4ewUalB4J6uoBgy HPSbDITHXIeTz9
> ISovMI9iFXzrS+Cjd7dk
> =HEVD
> -----END PGP SIGNATURE-----
luixrodix
luixrodix's Profile: http://forums.novell.com/member.php?userid=107647
View this thread: http://forums.novell.com/showthread.php?t=435894 -
SetObjectArrayElement causes memory leak
Hello There,
I have got a little problem that I'm not able to solve for myself. Look at this piece of
JNI code:
double** result = calculator->getResult();
jobjectArray table = env->NewObjectArray(height, env->FindClass("[D"), 0);
for (int i = 0;i < height;i++) {
jdoubleArray row = env->NewDoubleArray(width);
env->SetDoubleArrayRegion(row, 0, width, (jdouble*)result);
env->SetObjectArrayElement(table, i, row);
env->DeleteLocalRef(row);
This fragment causes a memory leak , but if I omit the env->SetObjectArrayElement(table, i, row);
call, there is no memory leak. I don't really know what exactly causes this memory leak and how
to fix it. Any help would be greatly appreciated ;-)
MichaelOk I think the code snippet I posted was not complete...
double** result = calculator->getResult();
jobjectArray table = env->NewObjectArray(height, env->FindClass("[D"), 0);
for (int i = 0;i < height;i++) {
jdoubleArray row = env->NewDoubleArray(width);
env->SetDoubleArrayRegion(row, 0, width, (jdouble*)result);
env->SetObjectArrayElement(table, i, row);
env->DeleteLocalRef(row);
jobject rawData = env->NewObject(classreg["data/rawdata1d"], methodIDreg["data/rawdata1d/init"], width, height);
env->SetObjectField(rawData, fieldIDreg["data/rawdata1d/data"], table);
return rawData;
The array I create is set as a member of a Java object which
is then returned by the native method. As long as this object
is in use by my program it's clear that the memory I allocated
for the array never gets released. But when the Java object is
no longer used by my program and the garbage collector releases
the memory occupied by this object, shouldn't it release the memory
occupied by the array I created in my native method too? Apparently
this is not the case, do I have to release the Java array for myself?
Michael
Edited by: Michael_JavaAddict on Aug 25, 2010 3:03 AM -
Do modules cause memory problems?
I have a big app that I decided to make modular. Everything
seemed to be going along smoothly at first as I started adding
modules. Now I have upwards of 40 modules and the app runs slow on
the client side and it takes forever for Flex Builder to build as
well. I kept getting an out of memory error so I upped my
FlexBuilder.ini parameter to -Xmx1024M. I am not getting the memory
problem, it does eventually build, but it takes a few minutes. I
guess my question is, does the number of modules I have in an
application have this big of an affect on building the application?
I have 1.5 gig of RAM and now allocating upwards of 2/3 of it to
Flex Builder if it needs it. Is there a better way or do I just
deal with it?If the modules are large it's possible that your stuck with
it but that is a rare situation. Likely you have a couple of things
you can do.
First is do not load a module until you really need to. This
I assume you already know. Inside each of the modules you will want
to take the same approach. Delay the creation of objects (UI or
otherwise) until the application actually needs them.
Second is you may have memory leaks: Might want to check out
this article by Grant Skinner if you have not already.
http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
My guess is that you have loitering objects and runaway event
listeners that all need to be stopped, closed down or de-referenced
or the garbage collector cannot collect them and eventually you run
out of memory.
If you have Flex 3 Beta 3 you can use the profiler to check
for Loitering Objects and verify that when you close certain
objects down that the memory is returning to where it should be or
at least reasonably close.
Either way the articles from Grant Skinner are a good
read. -
Does call to ptsname() cause memory leak?
Purify signalled that the call to ptsname() is a memory leak. ptsname() returns a char* and
apparently is doing this on the heap even though the man page says it is a static data area. My
question is whether we need to do a free() on the return from ptsname()?I believe that there was a memory leak problem with DataSocket 3.0 which came with LabVIEW 5.1. Try upgrading DataSocket to 4.0.
http://digital.ni.com/softlib.nsf/web%2Fall%20software?OpenView&Start=1&Count=500&Expand=6#6
If that does not work, the problem may not have been resolved until LabVIEW 6. Also, if you happened to be using the French version of LabVIEW, contact tech support, there was a specific problem there which does have a work around. -
Why does this extra REG EVENTS cause memory leak?
LabVIEW 8.6.1f1, Win XP/Vista
My client reported a memory leak in a particular section of my code - my own tests confirmed it.
Although I have found it and eliminated it, I still don't understand what's really happening.
The RTEC RECEIVER CONTROLLER vi produces a cluster with various (maybe 30) event refnums in it.
For this particular piece of code, I am only interested in 5 of those events.
I was experimenting with registering the cluster as a whole (it works), and I inadvertently left the 2nd REGISTER EVENTS function in place.
So there are TWO event registration refnums, but only one of them is being used.
As the program proceeds, more and more memory is being consumed by LabVIEW (as reported by Windows Resource Monitor). Leaving the program with this particular window running overnight would use up a gig or RAM.
I verified that nothing else was consuming it - disabling the actual data handling did not fix the problem - eliminating this extra registration did fix it.
So my question is - why?
The registration only happens once, and then there are a million events or more in a 12-hour period.
I can guess that the registration creates some sort of queue within LabVIEW for the events to reside in. With no EVENT structure tied to that refnum to consume the events, that queue expands forever.
Is that a reasonable guess, or is there something I am missing?
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And TricksCoastalMaineBird wrote:
I can guess that the registration creates some sort of queue within LabVIEW for the events to reside in. With no EVENT structure tied to that refnum to consume the events, that queue expands forever.
Is that a reasonable guess, or is there something I am missing?
Yes, it's a very reasonable guess and is most likely what's happening.
You might say "LabVIEW could see I'm not actually doing anything with the reference and could therefore optimize the code by ignoring it (which is something LV does in some other cases)", but I'm assuming this is a corner case whoever wrote the original code did not think about, because this could be implemented only in a case where the node neither outputs a reference nor gets one as an input.
Try to take over the world! -
FlushBeforeQueries Feature cause memory leak?
Hello,
I am testing out the latest release 3.2.4 with the "FlushBeforeQueries"
behavior enabled. But ran into a few problems:
1) First I tried it with action which imports a big business object (in
XML format - about 2.5MB) into our system with following configuration:
javax.jdo.option.IgnoreCache: false
kodo.ConnectionRetainMode: transaction
kodo.FlushBeforeQueries: with-connection
However, I got a java.lang.OutOfMemoryError;
By putting in some print-outs, I managed to locate where the error comes
from - from the call "tx.commit();".
2) Then I tried to import a smaller object (in XML format again about
1.1MB); and interestingly, it succeeds.
3) So I start to tweak with the configuration:
set the kodo.FlushBeforeQueries to true,
kodo.ConnectionRetainMode to persistence-manager or on-demand;
After trying quite a few combination, the only one which suppose to
enable the "FlushBeforeQueries" behavior is:
javax.jdo.option.IgnoreCache: false
kodo.ConnectionRetainMode: on-demand
kodo.FlushBeforeQueries: with-connection
However, with this setting, the kodo's log from kodo.Query says the
query has to be run in the memory and the whole object extent has to be
loaded due to setting: "javax.jdo.option.IgnoreCache=false and
kodo.FlushBeforeQueries=flase", so the query will be very slow. And this
log is correct - the system runs much much slower.
So, my questions are:
1) Has anyone observe the same as I did? if so, how did you resolve it?
2) Since the importing of smaller object (less persisted objects being
created) succeed, but bigger one fails, is it possible there is some
memory leaking associated with this FlushBeforeQueries thing?
3) According to the document from Kodo, configuration:
javax.jdo.option.IgnoreCache: false
kodo.ConnectionRetainMode: on-demand
kodo.FlushBeforeQueries: with-connection
should enable flushBeforeQuery, but why it is not in this release? or do
I miss something?
Thanks,
TaoWhatever it is, I have sent a test case yesterday morning. But there is
no answer yet - I am not even know if they got the code.
Once I get the explanation, or the solution from Kodo support team, I
will share it with you guys interested.
cheers,
Tao
Abe White wrote:
>
I'm interested in hearing about this since we also use this feature.Well, the short answer is that we don't think it's memory leak in Kodo. -
CVI dll to read XML file causes memory leak
Hello,
I am facing a memory leak issue when I execute a dll created using CVI to read a XML file.
Each iteration of the step is taking around 200k of memory.
Short description of the code:
Basically I am using a function created in CVI to read from an XML file by tag which 2 attributes: command and the response;
int GetCmdAndRsp(char XML_File[MAX_STR_SIZE], char tag[MAX_STR_SIZE], char Command[MAX_STR_SIZE], char Response[MAX_STR_SIZE], char ErrorDescription[MAX_STR_SIZE])
inputs:
- XML_File_path;
- tagToFind;
ouputs:
- Command;
- Response;
- Error;
Example:
XMLFile:
<WriteParameter Command="0x9 %i %i %i %i %i" Response = "0x8 V %i %i %i %i"/>
Execution:
error = GetCmdAndRsp("c:\\temp\\ACS_Messages.xml" ,"WriteParameter", cmd, rsp, errStr)
output:
error = 0
cmd = "0x9 %i %i %i %i %i"
rsp = "0x8 V %i %i %i %i"
errStr = "Unkown Error"
Everything is working correctly but I have this memory leak issue. Why am I having such memory consumption?? Is it a TestStand or CVI issue??
Each iteration I am loading the file, reading the file and discarding the file.
Attached you can find the CVI project, a TestStand sequence to test (ReadXML_test2.seq) and an example of a XML file I am using.
Please help me here.
Thaks in advance.
Regards,
Pedro Moreira
Attachments:
ReadXML_Prj.zip 1826 KBPedro,
When a TestStand step executes, its result will be stored by TestStand which will be later used for generating reports or logging data into database.
You are looking at the memory (private bytes) when the sequence file has not finished execution. So, the memory you are looking at, includes the memory used by TestStand to store result of the step. The memory used for storing results will be de-allocated after finishing the sequence file execution.
Hence, we dont know if there is actual memory leak or not. You should look at the memory, before and after executing sequence file instead of looking in between execution.
Also, here are some pointers that will be helpful for checking memory leak in an application:
1. TestStand is based on COM and uses BSTR in many function. BSTR caches the memory and because of the behavior, sometime you might get false notion of having memory leak. Hence, you need to use SetOaNoCache function OR set the OANOCACHE=1 environment variable to disable caching.
2. Execute the sequence file atleast once before doing the actual memory leak test. The dry run will make sure all static variables are initialized before doing memory leak test.
3. Make sure that the state of system or application is same when considering the Private bytes. Ex: Lets say ReportViewControl is not visible before you start executing sequence file. Then you note down the private bytes and then execute the sequence file. After finishing execution, make sure you close the ReportViewControl and then note down the private bytes once again to check if memory is leaked or not.
4. If there exists memory leak as you specified, it is possible that the leak is either in TestStand, or in your code. Make sure that your code doesn't leak by creating a small standalone application (probably a console application) which calls your code.
Detecting memory leaks in CVI is better explained in
http://www.ni.com/white-paper/10785/en/
http://www.ni.com/white-paper/7959/en/
- Shashidhar -
Applet calling javascript function causing memory leak
Hi,
I'm troubleshooting one memory leak issue in my application and to do that I created one simple Java applet and HTML + javascript function to locate the problem.
Basically it's an applet calling a javascript function using a timer. The javascript function simply does nothing.
I tested in IE 8.0 and JRE 1.6.0_23-b05 and memory of IE keeps increasing.
I saw this bug http://bugs.sun.com/view_bug.do?bug_id=6857340 which seems related with my issue, but if I understand correctly from the page, the issue should have been fixed.
I posted this message to find out if others also find same issue and if there's a solution for this. If I comment out window.call("dummy", null); , memory will not climb up.
Java code
+public class Main extends Applet implements Runnable {+
public Applet currentApplet= this ;
+ public JSObject window = null;+
+public void run(){+
+ System.out.println("run..");+
+ }+
+public void start(){+
window = JSObject.getWindow(this);
int delay = 300; //milliseconds
+ActionListener taskPerformer = new ActionListener() {+
+public void actionPerformed(ActionEvent evt) {+
window.call("dummy", null);
+}+
+};+
new Timer(delay, taskPerformer).start();
+ }+
+public static void main(String[] args) {+
+ System.out.println("start...");+
+ Main main = new Main();+
+ main.start();+
+ }+
+}+
Javascript source code
+<html>+
+<head>+
+<script>+
+function dummy() {+
+ +
+}+
+</script>+
+</head>+
+<body>+
+<applet .... >+
+...+
+</html>+Try this url:
http://www.inquiry.com/techtips/java_pro/10MinuteSolutions/callingJavaScript.asp
It also provides some examples. -
Flash cause Memory leak problem under IE
I have encountered a problem when running a flash with
countdown scripts inside under IE.
The IE in memory will become bigger and bigger and IE will
finally eat up 50% of my processing time.
My script cannot be officially go online of this problem.
Similar flash by other with the same problem in IE:
http://www.zsg.com/
*** additional info: the leak will reset if the browser is
being minimized.
Can any one help?
Thanks a lot!
P.S My countdown script play no problem with Firefox 2.0.0.14
Flash player 9.124.0
IE version 7.0.5730.13
OS: Win XP with SP2
My scripts is just a simple onEnterFrame with calculation
inside until the difference between current time and target time is
<=0(target time - difference time)
Thanks a lot!Which process is not releasing memory? Which thread within that process? What do the process monitoring programs from Technet/SysInternals (see
https://technet.microsoft.com/en-us/sysinternals/bb795533.aspx ) show about the memory that is not being released?
There may be memory leaks in Coded UI but more likely the leaks are in the test cases and the way they use Coded UI. I think you need to do some more investigation and show its results before getting much more than just general advice here.
Regards
Adrian -
Hi,
You can visit http://brandy.pararuk.com and see just 15 flying comets animated with KineticJS library.
When I run it (viewing Windows Task Manager) I see that firefox.exe consumes 100Mb of memory every second up to full avaliable memory and hangs on Windows.
I've tested this page also on desktop with: Chrome, Safari, IE9 and on my Android tablet with: Firefox Beta, Chrome and Android browser - page works good everywhere, except of desktop Firefox.
Thank you for help.Did you try to disable extensions like Firebug?
Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
*Do NOT click the Reset button on the Safe mode start window or otherwise make changes.
*https://support.mozilla.org/kb/Safe+Mode
*https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes -
Flex4 TextInput module unload memory leak
Hi, i have an application (Application.mxml) that loads a simple module (Charts.mxml) using module loader. The module has a component spark.components.TextInput.
When i unload the module, using the profiler in flash builder the module stay alive and not get garbage collected. Any answer for this?
Application.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
public function load():void {
appLoader.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
appLoader.loadModule("com/scanntech/Charts.swf");
public function unload():void {
btnUnload.setFocus();
appLoader.applicationDomain = null;
appLoader.unloadModule();
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:Button id="btnLoad" label="load" click="load()"/>
<s:Button id="btnUnload" label="unload" click="unload()"/>
<mx:ModuleLoader id="appLoader" width="100%" height="100%" />
</s:Application>
Charts.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<!-- No Leak -->
<!--<s:CheckBox />-->
<!--<s:TextArea />-->
<!-- Leak -->
<s:TextInput />
</mx:Module>
PD: sorry my bad englishYou don't need:
appLoader.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
Thanks,
Gaurav Jain
Flex SDK Team
http://www.gauravj.com
Maybe you are looking for
-
I have a macbook pro from fall 2010. I have been using my external HD as my primary itunes folder for the past 7 yrs ( i.e it is organized by itunes default categorization, etc). However, there is some overlap between my external HD itunes folder and
-
Accounts Payable Check Register
Hello, Does anyone have any advice they can share with regard to creating an InfoProvider that would contain check register information for Accounts Payable? I have looked through Business Content for Financials but have not been able to find anythi
-
Lost list of my wifi networks after using migration assistant / time machine
After using migration assistant / time machine to set up my new Mac I now miss the list of stored preferred Wlan/WiFi networks. So the passwords of wireless networks I. Used in the past are all gone. Why is time machine not putting those on my new Ma
-
CRM Sales structure and persons download to HCM
Hi all, I've found many threads and documentation about downloading master data from HR into CRM but I'm interested in the reverse process. Even when integration between CRM and HCM is described, it seems to refer (only) to data transfer from HCM to
-
Plug-in issues causing one of my games to continuously crash with a 'stop plug-in'
Hello. I have tried and tried for months to fix a 'stop plug-in' error that causes one of my games to crash every two minutes. I have un installed and re installed, allowed more memory for that game to store on my computer, and I have been to every