ImageComponent2DRetained.set memory leak
hi,
anybody aware of a memory leak in imagecomponent2DRetained.set??
i am using java3d 1.3.1.
my application will creates Text2D objs and then detach them from the scenegraph and create new Text2D objs over and over again.
Somehow, the array of bytes in imagecomponent2dretained does not get cleared.
Any ideas please??
yes.. it is registered and is solved in the 1.2.1 release.
However i am still getting a leak in 1.3.1. Strange.
Since node.clonetree and text2d also uses image2dcomponentretained.set,
this should be a big problem.
However, i can't spot the leak in image2dcomponentretained.set. Can anyone here spot it??
Similar Messages
-
My computer is running low on RAM, and when I look at what processes are using the most memory, firefox is the number one using between 28,000 to 93,000k, so I'm guessing that it has a memory leak.
And because of that memory leak I have to update firefox, however I really dislike the newest version of firefox and I'd prefer to stick with the version I have, which is 3.5.Often the memory problems are not just from Firefox in isolation, but partly relating to all the extensions available for it and then the videos and animations it runs on media rich sites.
The first thing to do is to upgrade to firefox 3.6 which is at least a supported version (Maybe not for much longer)
* see [[updating firefox]]
Next version after 3.6 is 4, you should avoid that, it did have some memory problems, that were worse than 3,6 and firefox 4 is no longer secure or supported.
The techies at Firefox have been working on memory problems recently and have made many improvements, but some of these improvements are only seen in the trial versions of Firefox.
I would in fact suggest you upgrade to Firefox 5 the current release version (soon to be replaced with Firefox 6)
I am able to run Firefox v3.6 to v8 on legacy XPs with less than 1GB RAM. Firefox in itself is not necessarily very demanding in terms of RAM. I am not sure what the figures are you are quoting, or whether they are high. ( Note 1Gb is in the order of 1 000 000 k )
As for not liking the set-up of new versions of Firefox, there is quite abit that can be changed, maybe you would be able to configure it more to your liking with little effort. -
Oracle JDBC Thin Driver Memory leak in scrollable result set
Hi,
I am using oracle 8.1.7 with oracle thin jdbc driver (classes12.zip) with jre 1.2.2. When I try to use the scrollable resultset and fetch records with the default fetch size, I run into memory leaks. When the records fetched are large(10000 records) over a period of access I get "outofmemory" error because of the leak. There is no use increasing the heap size as the leak is anyhow there.
I tried using optimizeit and found there is a huge amout of memory leak for each execution of scrollable resultsets and this memory leak is propotional to the no of records fetched. This memory leak is not released even when i set the resultset,statement objects to null. Also when i use methods like scrollabelresultset.last() this memory leak increases.
So is this a problem with the driver or i am doing some wrong.
If some of you can help me with a solution to solve this it would be of help. If needed i can provide some statistics of these memory leaks using optimize it and share the code.
Thanks
RajeshThis thread is ancient and the original was about the 8.1.7 drivers. Please start a new thread. Be sure to include driver and database versions, stack traces, sample code and why you think there is a memory leak.
Douglas -
Memory leak in JSpinner implementation (maybe others?)
Hi,
I am developing an application using Java and Swing, and have run into some problems with memory leaks. After examining the source code and making an example program (provided below), I can only come to the conclusion that there is a bug in the implementation of JSpinner in Sun Java 1.6.0_03.
If one uses a custom model with the JSpinner, it attaches itself as a listener to the model. However, it never removes the listening connection, even if the model is changed. This causes the JSpinner to be kept in memory as long as the model exists, even if all other references to the component have been removed.
An example program is available at http://eddie.dy.fi/~sampo/ModelTest.java . It is a simple swing program that has the JSpinner and two buttons, the first of which writes to stdout the listeners of the original model and the second changes the spinner model to a newly-created model. A sample output is below:
Running on 1.6.0_03 from Sun Microsystems Inc.
Listeners before connecting to JSpinner:
Model value is 0, 0 listeners connected:
Listeners after connecting to JSpinner:
Model value is 0, 2 listeners connected:
1: interface javax.swing.event.ChangeListener
2: javax.swing.JSpinner$ModelListener@9971ad
Listeners now:
Model value is 8, 2 listeners connected:
1: interface javax.swing.event.ChangeListener
2: javax.swing.JSpinner$ModelListener@9971ad
Changing spinner model.
Listeners now:
Model value is 8, 2 listeners connected:
1: interface javax.swing.event.ChangeListener
2: javax.swing.JSpinner$ModelListener@9971adThis shows that even though the model of the JSpinner has been changed, it still listens to the original model. I haven't looked at other components whether they retain connections to the old models as well.
In my case, I have an adaptor-model which provides a SpinnerModel interface to the actual data. The adaptor is implemented so that it listens to the underlying model only when it itself is being listened to. If the JComponents using the model were to remove the listening connections, it, too, would be automatically garbage-collected. However, since JSpinner does not remove the connections, the adaptor also continues to listen to the underlying model, and neither can be garbage-collected.
All in all, the listener-connections seem to be a very easy place to make memory leaks in Java and especially in Swing. However, as I see it, it would be a simple matter to make everything work automatically with one simple rule: Listen to the models only when necessary.
If a component is hidden (or alternatively has no contact to a parent JFrame or equivalent), it does not need to listen to the model and should remove the connections. When the component is again set visible (or connected to a frame) it can re-add the connections and re-read the current model values just as it does when initializing the component. Similarly, any adaptor-models should listen to the underlying model only when it itself is being listened to.
If the components were implemented in this way, one could simply remove a component from the frame and throw it away, and automatically any listener-connections will be removed and it can be garbage-collected. Similarly any adaptor-models are collected when they are no longer in use.
Changing the API implementation in this way would not require any changes to applications, as the only thing that changes are the listener-connections. Currently used separate connection-removing methods should still work, though they would be unnecessary any more. The API would look exactly the same from the view of an application programmer, only that she would not need to care about remnant listening connections. (As far as I can tell, the current API specification would allow the API to be implemented as described above, but it should of course require it to be implemented in such a way.)
Am I missing something, or is there some valid reason why the API is not implemented like this?
PS. I'm new to these forums, so if there is a better place to post these reports, please tell me. Thanks.Another cognition: It's the following code, that causes the memory to be accumulated:
obj = m_orb.resolve_initial_references("NameService");
ctx = NamingContextExtHelper.narrow(obj);For the first 4 calls to this code the memory usage of the nameservice is unchanged. From the 5th to the 8th call, it's increased by approx. 10KB per call. And thenceforward (beginning with the 9th call) it's increasing by approx. 10MB.
What's going wrong here? -
T61 with memory leak on XP for driver battc.sys
Hi
I have an issue with XP where the battc.sys module that is part of Windows XP and responsible for the kernel side of monitoring the battery status. This module continually leaks memory until I have no more kernel paged resources left and programs start to fail on my laptop.
I raised a support case for this with Microsoft and after some investigation and upgrading to the latest T61 power drivers that were released a few days ago on the Lenovo site, MS support told me it is a fault of the T61 and that I would need to disable Microsoft APCI support to stop this memory leak from occuring and to take the issue up with Lenovo.
I have used the verifier tool to confirm that it is the Windows XP SP3 battc.sys memory module leaking.
I am running the latest T61 drivers and fully patch with MS drivers on SP3.
As MS have told me it is the fault of the T61 I am posting this issue here.
Thanks
StephenIt is memory available to the kernelwhich itself does not show under a process in task manager as far as I am aware (unles it is taken account as part of the system process).
The best way to measure the available kernel memory space available is by using sysinternals procexp.
You need to download procexp and also install the windows debugging tools from Microsoft. Then in procexp set the "Options > Configure Symbols : Debughlp.dll path" to the new debughlp.dll installed with your debu tools and set the symbols path to srv*c:\Symbols*http://msdl.microsoft.com/download/symbols
Then you can choose in procexp "View > System Information" and see the used and total paged and non-paged kernel memory space.
poolmon helps monitor all the symbols that are taking up this memory and verifier lets you drill down to the exact module and the changes in memory for a module that is occuring.
Here are two really good links on it
http://blogs.msdn.com/ntdebugging/archive/2006/12/18/Understanding-Pool-Consumption-and-Event-ID_3A0...
http://blogs.msdn.com/ntdebugging/archive/2008/05/08/tracking-down-mmst-paged-pool-usage.aspx
In my poolmon i notice that Mmst and battc are taking alot of memory after my computer has been running for some time. Mmst being high is normal but battc should not continually be growing as it is which is why I raised the case to MS but they want verification it is not a Lenovo issue. -
Allocated memory pool was not deleted! 1 GB memory leak is too much for me!
Dear Sirs. I found that DB environment, that was configured to use 1 GB cache size, won't free it when closed! Why? First I tried to open and close environment and got the following:
Detected memory leaks!
Dumping objects ->
{596} normal block at 0x01970040, 1048596 bytes long.
Data: < > 14 00 10 00 DB DB DB DB 0B 00 10 00 01 00 00 00
{578} normal block at 0x00397978, 464 bytes long.
Data: < > D0 01 00 00 DB DB DB DB C7 01 00 00 01 00 00 00
Object dump complete.
I have and idea that BDB will reuse the memory, rite? OK, let's try to create the same environment and open it. After environment was opened, closed, opened again and again closed, I got the following:
Detected memory leaks!
Dumping objects ->
{3663} normal block at 0x01B80040, 1048596 bytes long.
Data: < > 14 00 10 00 DB DB DB DB 0B 00 10 00 01 00 00 00
{3645} normal block at 0x00396E60, 464 bytes long.
Data: < > D0 01 00 00 DB DB DB DB C7 01 00 00 01 00 00 00
{596} normal block at 0x01970040, 1048596 bytes long.
Data: < > 14 00 10 00 DB DB DB DB 0B 00 10 00 01 00 00 00
{578} normal block at 0x00397978, 464 bytes long.
Data: < > D0 01 00 00 DB DB DB DB C7 01 00 00 01 00 00 00
Object dump complete.
So memory was not reused, nor deallocated.
By the way, you may be interested in other leak I found, but fixed, see
Replication manager memory leak when setting local site information.
This leak is more serious, I am not sure I will fix it quickly. Maybe I'm doing something wrong? Could you please suggest something?
Thanks in advance!
With regards,
Vladislav.OK, the problem solved by fixing code in file 'log.c', method '__log_dbenv_refresh'.
Just added the code that deallocates memory of bulk buffer.
if (IS_ENV_REPLICATED(dbenv))
if (lp->bulk_buf != INVALID_ROFF)
__db_shalloc_free(&dblp->reginfo, lp->bulk_buf);
lp->bulk_buf = INVALID_ROFF;
lp->bulk_len = 0;
lp->bulk_off = 0;
It was allocated in the '__log_open' function, by the following code:
lp->ready_lsn = lp->lsn;
if (IS_ENV_REPLICATED(dbenv)) {
if ((ret = __db_shalloc(&dblp->reginfo, MEGABYTE, 0,
&bulk)) != 0)
goto err;
lp->bulk_buf = R_OFFSET(&dblp->reginfo, bulk);
lp->bulk_len = MEGABYTE;
lp->bulk_off = 0;
} else {
lp->bulk_buf = INVALID_ROFF;
lp->bulk_len = 0;
lp->bulk_off = 0;
Sorry for time taken to read my posts, I was really needy in quick help, but solved problems myself. -
Pro*c multithreaded application has memory leak
Hi there,
I posted this message a week ago in OCI section, nobody answer me.
I am really curious if my application has a bug or the pro*c has a bug.
Anyone can compile the sample code and test it easily.
I made multithreaded application which queries dynamic SQL, it works.
But the memory leaks when i query the SQL statement.
The more memory leaks, the more i query the SQL statement, even same SQL
statement.
I check it with top, shell command.
My machine is SUN E450, Solaris 8. Oracle 9.2.0.1
Compiler : gcc (GCC) 3.2.2
I changed source code which is from
$(ORACLE_HOME)/precomp/demo/proc/sample10.pc
the sample10 doesn't need to be multithreaded. But i think it has to work
correctly if i changed it to multithreaded application.
the make file and source code will be placed below.
I have to figure out the problem.
Please help
Thanks in advance,
the make file is below
HOME = /user/jkku
ORA = $(ORACLE_HOME)
CC = gcc
PROC = proc
LC_INCL = -I$(HOME)/work/dbmss/libs/include
lc_incl = include=$(HOME)/work/dbmss/libs/include
SYS_INCL =
sys_incl =
ORA_INCL = -I. \
-I$(ORA)/precomp/public \
-I$(ORA)/rdbms/public \
-I$(ORA)/rdbms/demo \
-I$(ORA)/rdbms/pbsql/public \
-I$(ORA)/network/public \
-DSLMXMX_ENABLE -DSLTS_ENABLE -D_SVID_GETTOD
INCLUDES = $(LC_INCL) $(SYS_INCL) $(ORA_INCL)
includes = $(lc_incl) $(sys_incl)
LC_LIBS =
SYS_LIBS = -lpthread -lsocket -lnsl -lrt
ORA_LIBS = -L$(ORA)/lib/ -lclntsh
LIBS = $(LC_LIBS) $(SYS_LIBS) $(ORA_LIBS)
# Define C Compiler flags
CFLAGS += -D_Solaris64_ -m64
CFLAGS += -g -D_REENTRANT
# Define pro*c Compiler flags
PROCFLAGS += THREADS=YES
PROCFLAGS += CPOOL=YES
# Our object files
PRECOMPS = sample10.c
OBJS = sample10.o
.SUFFIXES: .o .c .pc
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $*.c
.pc.c:
$(PROC) $(PROCFLAGS) $(includes) $*.pc $*.c
all: sample10
sample10: $(PRECOMPS) $(OBJS)
$(CC) $(CFLAGS) -o sample10 $(OBJS) $(LIBS)
clean:
rm -rf *.o sample10 sample10.c
the source code is below which i changed the oracle sample10.pc to
multithreaded application.
Sample Program 10: Dynamic SQL Method 4
This program connects you to ORACLE using your username and
password, then prompts you for a SQL statement. You can enter
any legal SQL statement. Use regular SQL syntax, not embedded SQL.
Your statement will be processed. If it is a query, the rows
fetched are displayed.
You can enter multi-line statements. The limit is 1023 characters.
This sample program only processes up to MAX_ITEMS bind variables and
MAX_ITEMS select-list items. MAX_ITEMS is #defined to be 40.
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <sqlda.h>
#include <stdlib.h>
#include <sqlcpr.h>
/* Maximum number of select-list items or bind variables. */
#define MAX_ITEMS 40
/* Maximum lengths of the names of the
select-list items or indicator variables. */
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30
#ifndef NULL
#define NULL 0
#endif
/* Prototypes */
#if defined(__STDC__)
void sql_error(void);
int oracle_connect(void);
int alloc_descriptors(int, int, int);
int get_dyn_statement(void);
void set_bind_variables(void);
void process_select_list(void);
void help(void);
#else
void sql_error(/*_ void _*/);
int oracle_connect(/*_ void _*/);
int alloc_descriptors(/*_ int, int, int _*/);
int get_dyn_statement(/* void _*/);
void set_bind_variables(/*_ void -*/);
void process_select_list(/*_ void _*/);
void help(/*_ void _*/);
#endif
char *dml_commands[] = {"SELECT", "select", "INSERT", "insert",
"UPDATE", "update", "DELETE", "delete"};
EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE sqlca;
EXEC SQL BEGIN DECLARE SECTION;
char dyn_statement[1024];
EXEC SQL VAR dyn_statement IS STRING(1024);
EXEC SQL END DECLARE SECTION;
EXEC ORACLE OPTION (ORACA=YES);
EXEC ORACLE OPTION (RELEASE_CURSOR=YES);
SQLDA *bind_dp;
SQLDA *select_dp;
/* Define a buffer to hold longjmp state info. */
jmp_buf jmp_continue;
char *db_uid="dbmuser/dbmuser@dbmdb";
sql_context ctx;
int err_sql;
enum{
SQL_SUCC=0,
SQL_ERR,
SQL_NOTFOUND,
SQL_UNIQUE,
SQL_DISCONNECT,
SQL_NOTNULL
int main()
int i;
EXEC SQL ENABLE THREADS;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
/* Connect to the database. */
if (connect_database() < 0)
exit(1);
EXEC SQL CONTEXT USE :ctx;
/* Process SQL statements. */
for (;;)
/* Allocate memory for the select and bind descriptors. */
if (alloc_descriptors(MAX_ITEMS, MAX_VNAME_LEN, NAME_LEN) != 0)
exit(1);
(void) setjmp(jmp_continue);
/* Get the statement. Break on "exit". */
if (get_dyn_statement() != 0)
break;
EXEC SQL PREPARE S FROM :dyn_statement;
EXEC SQL DECLARE C CURSOR FOR S;
/* Set the bind variables for any placeholders in the
SQL statement. */
set_bind_variables();
/* Open the cursor and execute the statement.
* If the statement is not a query (SELECT), the
* statement processing is completed after the
* OPEN.
EXEC SQL OPEN C USING DESCRIPTOR bind_dp;
/* Call the function that processes the select-list.
* If the statement is not a query, this function
* just returns, doing nothing.
process_select_list();
/* Tell user how many rows processed. */
for (i = 0; i < 8; i++)
if (strncmp(dyn_statement, dml_commands, 6) == 0)
printf("\n\n%d row%c processed.\n", sqlca.sqlerrd[2], sqlca.sqlerrd[2] == 1 ? '\0' : 's');
break;
/* Close the cursor. */
EXEC SQL CLOSE C;
/* When done, free the memory allocated for pointers in the bind and
select descriptors. */
for (i = 0; i < MAX_ITEMS; i++)
if (bind_dp->V != (char *) 0)
free(bind_dp->V);
free(bind_dp->I); /* MAX_ITEMS were allocated. */
if (select_dp->V != (char *) 0)
free(select_dp->V);
free(select_dp->I); /* MAX_ITEMS were allocated. */
/* Free space used by the descriptors themselves. */
SQLSQLDAFree(ctx, bind_dp);
SQLSQLDAFree(ctx, select_dp);
} /* end of for(;;) statement-processing loop */
disconnect_database();
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL COMMIT WORK RELEASE;
puts("\nHave a good day!\n");
return;
* Allocate the BIND and SELECT descriptors using sqlald().
* Also allocate the pointers to indicator variables
* in each descriptor. The pointers to the actual bind
* variables and the select-list items are realloc'ed in
* the set_bind_variables() or process_select_list()
* routines. This routine allocates 1 byte for select_dp->V
* and bind_dp->V, so the realloc will work correctly.
alloc_descriptors(size, max_vname_len, max_iname_len)
int size;
int max_vname_len;
int max_iname_len;
int i;
* The first sqlald parameter determines the maximum number of
* array elements in each variable in the descriptor. In
* other words, it determines the maximum number of bind
* variables or select-list items in the SQL statement.
* The second parameter determines the maximum length of
* strings used to hold the names of select-list items
* or placeholders. The maximum length of column
* names in ORACLE is 30, but you can allocate more or less
* as needed.
* The third parameter determines the maximum length of
* strings used to hold the names of any indicator
* variables. To follow ORACLE standards, the maximum
* length of these should be 30. But, you can allocate
* more or less as needed.
if ((bind_dp =
SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) ==
(SQLDA *) 0)
fprintf(stderr,
"Cannot allocate memory for bind descriptor.");
return -1; /* Have to exit in this case. */
if ((select_dp =
SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) == (SQLDA *)
0)
fprintf(stderr,
"Cannot allocate memory for select descriptor.");
return -1;
select_dp->N = MAX_ITEMS;
/* Allocate the pointers to the indicator variables, and the
actual data. */
for (i = 0; i < MAX_ITEMS; i++) {
bind_dp->I = (short *) malloc(sizeof (short));
select_dp->I = (short *) malloc(sizeof(short));
bind_dp->V = (char *) malloc(1);
select_dp->V = (char *) malloc(1);
return 0;
int get_dyn_statement()
char *cp, linebuf[256];
int iter, plsql;
for (plsql = 0, iter = 1; ;)
if (iter == 1)
printf("\nSQL> ");
dyn_statement[0] = '\0';
fgets(linebuf, sizeof linebuf, stdin);
cp = strrchr(linebuf, '\n');
if (cp && cp != linebuf)
*cp = ' ';
else if (cp == linebuf)
continue;
if ((strncmp(linebuf, "EXIT", 4) == 0) ||
(strncmp(linebuf, "exit", 4) == 0))
return -1;
else if (linebuf[0] == '?' ||
(strncmp(linebuf, "HELP", 4) == 0) ||
(strncmp(linebuf, "help", 4) == 0))
help();
iter = 1;
continue;
if (strstr(linebuf, "BEGIN") ||
(strstr(linebuf, "begin")))
plsql = 1;
strcat(dyn_statement, linebuf);
if ((plsql && (cp = strrchr(dyn_statement, '/'))) ||
(!plsql && (cp = strrchr(dyn_statement, ';'))))
*cp = '\0';
break;
else
iter++;
printf("%3d ", iter);
return 0;
void set_bind_variables()
int i, n;
char bind_var[64];
/* Describe any bind variables (input host variables) */
EXEC SQL WHENEVER SQLERROR DO sql_error();
bind_dp->N = MAX_ITEMS; /* Initialize count of array elements. */
EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;
/* If F is negative, there were more bind variables
than originally allocated by sqlald(). */
if (bind_dp->F < 0)
printf ("\nToo many bind variables (%d), maximum is %d\n.",
-bind_dp->F, MAX_ITEMS);
return;
/* Set the maximum number of array elements in the
descriptor to the number found. */
bind_dp->N = bind_dp->F;
/* Get the value of each bind variable as a
* character string.
* C contains the length of the bind variable
* name used in the SQL statement.
* S contains the actual name of the bind variable
* used in the SQL statement.
* L will contain the length of the data value
* entered.
* V will contain the address of the data value
* entered.
* T is always set to 1 because in this sample program
* data values for all bind variables are entered
* as character strings.
* ORACLE converts to the table value from CHAR.
* I will point to the indicator value, which is
* set to -1 when the bind variable value is "null".
for (i = 0; i < bind_dp->F; i++)
printf ("\nEnter value for bind variable %.*s: ",
(int)bind_dp->C, bind_dp->S);
fgets(bind_var, sizeof bind_var, stdin);
/* Get length and remove the new line character. */
n = strlen(bind_var) - 1;
/* Set it in the descriptor. */
bind_dp->L = n;
/* (re-)allocate the buffer for the value.
sqlald() reserves a pointer location for
V but does not allocate the full space for
the pointer. */
bind_dp->V = (char *) realloc(bind_dp->V, (bind_dp->L + 1));
/* And copy it in. */
strncpy(bind_dp->V, bind_var, n);
/* Set the indicator variable's value. */
if ((strncmp(bind_dp->V, "NULL", 4) == 0) ||
(strncmp(bind_dp->V, "null", 4) == 0))
*bind_dp->I = -1;
else
*bind_dp->I = 0;
/* Set the bind datatype to 1 for CHAR. */
bind_dp->T = 1;
return;
void process_select_list()
int i, null_ok, precision, scale;
if ((strncmp(dyn_statement, "SELECT", 6) != 0) &&
(strncmp(dyn_statement, "select", 6) != 0))
select_dp->F = 0;
return;
/* If the SQL statement is a SELECT, describe the
select-list items. The DESCRIBE function returns
their names, datatypes, lengths (including precision
and scale), and NULL/NOT NULL statuses. */
select_dp->N = MAX_ITEMS;
EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;
/* If F is negative, there were more select-list
items than originally allocated by sqlald(). */
if (select_dp->F < 0)
printf ("\nToo many select-list items (%d), maximum is %d\n",
-(select_dp->F), MAX_ITEMS);
return;
/* Set the maximum number of array elements in the
descriptor to the number found. */
select_dp->N = select_dp->F;
/* Allocate storage for each select-list item.
sqlprc() is used to extract precision and scale
from the length (select_dp->L).
sqlnul() is used to reset the high-order bit of
the datatype and to check whether the column
is NOT NULL.
CHAR datatypes have length, but zero precision and
scale. The length is defined at CREATE time.
NUMBER datatypes have precision and scale only if
defined at CREATE time. If the column
definition was just NUMBER, the precision
and scale are zero, and you must allocate
the required maximum length.
DATE datatypes return a length of 7 if the default
format is used. This should be increased to
9 to store the actual date character string.
If you use the TO_CHAR function, the maximum
length could be 75, but will probably be less
(you can see the effects of this in SQL*Plus).
ROWID datatype always returns a fixed length of 18 if
coerced to CHAR.
LONG and
LONG RAW datatypes return a length of 0 (zero),
so you need to set a maximum. In this example,
it is 240 characters.
printf ("\n");
for (i = 0; i < select_dp->F; i++)
char title[MAX_VNAME_LEN];
/* Turn off high-order bit of datatype (in this example,
it does not matter if the column is NOT NULL). */
sqlnul ((unsigned short *)&(select_dp->T), (unsigned short
*)&(select_dp->T), &null_ok);
switch (select_dp->T)
case 1 : /* CHAR datatype: no change in length
needed, except possibly for TO_CHAR
conversions (not handled here). */
break;
case 2 : /* NUMBER datatype: use sqlprc() to
extract precision and scale. */
sqlprc ((unsigned int *)&(select_dp->L), &precision,
&scale);
/* Allow for maximum size of NUMBER. */
if (precision == 0) precision = 40;
/* Also allow for decimal point and
possible sign. */
/* convert NUMBER datatype to FLOAT if scale > 0,
INT otherwise. */
if (scale > 0)
select_dp->L = sizeof(float);
else
select_dp->L = sizeof(int);
break;
case 8 : /* LONG datatype */
select_dp->L = 240;
break;
case 11 : /* ROWID datatype */
case 104 : /* Universal ROWID datatype */
select_dp->L = 18;
break;
case 12 : /* DATE datatype */
select_dp->L = 9;
break;
case 23 : /* RAW datatype */
break;
case 24 : /* LONG RAW datatype */
select_dp->L = 240;
break;
/* Allocate space for the select-list data values.
sqlald() reserves a pointer location for
V but does not allocate the full space for
the pointer. */
if (select_dp->T != 2)
select_dp->V = (char *) realloc(select_dp->V,
select_dp->L + 1);
else
select_dp->V = (char *) realloc(select_dp->V,
select_dp->L);
/* Print column headings, right-justifying number
column headings. */
/* Copy to temporary buffer in case name is null-terminated */
memset(title, ' ', MAX_VNAME_LEN);
strncpy(title, select_dp->S, select_dp->C);
if (select_dp->T == 2)
if (scale > 0)
printf ("%.*s ", select_dp->L+3, title);
else
printf ("%.*s ", select_dp->L, title);
else
printf("%-.*s ", select_dp->L, title);
/* Coerce ALL datatypes except for LONG RAW and NUMBER to
character. */
if (select_dp->T != 24 && select_dp->T != 2)
select_dp->T = 1;
/* Coerce the datatypes of NUMBERs to float or int depending on
the scale. */
if (select_dp->T == 2)
if (scale > 0)
select_dp->T = 4; /* float */
else
select_dp->T = 3; /* int */
printf ("\n\n");
/* FETCH each row selected and print the column values. */
EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop;
for (;;)
EXEC SQL FETCH C USING DESCRIPTOR select_dp;
/* Since each variable returned has been coerced to a
character string, int, or float very little processing
is required here. This routine just prints out the
values on the terminal. */
for (i = 0; i < select_dp->F; i++)
if (*select_dp->I < 0)
if (select_dp->T == 4)
printf ("%-*c ",(int)select_dp->L+3, ' ');
else
printf ("%-*c ",(int)select_dp->L, ' ');
else
if (select_dp->T == 3) /* int datatype */
printf ("%*d ", (int)select_dp->L,
*(int *)select_dp->V);
else if (select_dp->T == 4) /* float datatype */
printf ("%*.2f ", (int)select_dp->L,
*(float *)select_dp->V);
else /* character string */
printf ("%-*.*s ", (int)select_dp->L,
(int)select_dp->L, select_dp->V);
printf ("\n");
end_select_loop:
return;
void help()
puts("\n\nEnter a SQL statement or a PL/SQL block at the SQL> prompt.");
puts("Statements can be continued over several lines, except");
puts("within string literals.");
puts("Terminate a SQL statement with a semicolon.");
puts("Terminate a PL/SQL block (which can contain embedded
semicolons)");
puts("with a slash (/).");
puts("Typing \"exit\" (no semicolon needed) exits the program.");
puts("You typed \"?\" or \"help\" to get this message.\n\n");
int connect_database()
err_sql = SQL_SUCC;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
EXEC SQL CONTEXT ALLOCATE :ctx;
EXEC SQL CONTEXT USE :ctx;
EXEC SQL CONNECT :db_uid;
if(err_sql != SQL_SUCC){
printf("err => connect database(ctx:%ld, uid:%s) failed!\n", ctx, db_uid);
return -1;
return 1;
int disconnect_database()
err_sql = SQL_SUCC;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
EXEC SQL CONTEXT USE :ctx;
EXEC SQL COMMIT WORK RELEASE;
EXEC SQL CONTEXT FREE:ctx;
return 1;
void sql_error()
printf("err => %.*s", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);
printf("in \"%.*s...\'\n", oraca.orastxt.orastxtl, oraca.orastxt.orastxtc);
printf("on line %d of %.*s.\n\n", oraca.oraslnr, oraca.orasfnm.orasfnml,
oraca.orasfnm.orasfnmc);
switch(sqlca.sqlcode) {
case -1: /* unique constraint violated */
err_sql = SQL_UNIQUE;
break;
case -1012: /* not logged on */
case -1089:
case -3133:
case -1041:
case -3114:
case -3113:
/* �6�Ŭ�� shutdown�ǰų� �α��� ���°� �ƴҶ� ��b�� �õ� */
/* immediate shutdown in progress - no operations are permitted */
/* end-of-file on communication channel */
/* internal error. hostdef extension doesn't exist */
err_sql = SQL_DISCONNECT;
break;
case -1400:
err_sql = SQL_NOTNULL;
break;
default:
err_sql = SQL_ERR;
break;
EXEC SQL CONTEXT USE :ctx;
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK;
void sql_not_found()
err_sql = SQL_NOTFOUND;Hi Jane,
What version of Berkeley DB XML are you using?
What is your operating system and your hardware platform?
For how long have been the application running?
What is your current container size?
What's set for EnvironmentConfig.setThreaded?
Do you know if containers have previously not been closed correctly?
Can you please post the entire error output?
What's the JDK version, 1.4 or 1.5?
Thanks,
Bogdan -
Firefox memory leak, how to fix?
I've noticed i've been having memory leaks since quite a few versions before the latest one (33.1.1) and the problem still continues, i notice this more when i leave firefox open for awhile, sometimes only with youtube and couple of other "static" pages on, but i've got the same results without youtube.
Today i decided to ask the question, since i haven't seen any memory leak bugfixes in the recent changelogs and it becomes quite a problem to me because i leave it all day open and when it happens it forces me to restart (not really forces but i don't like having an 1.3GB process when i can have the same for 500~ ...)
I don't believe any of my extras are the reason for it, i've tested them over the pass'ed versions, removed a few, installed a few, always same problem.
All of this running WIndows 7 Ultimate 64-bits .
i've researched and found it's a "common" problem, but no really solution or expected bugfix soon or anything, i'm still to test it without any 3rd part extensions or plugins, but i don't (think) have any extensions that may cause this because like i said, i've changed them quite a few times.
Here is my extension list: http://i.imgur.com/Rk80ajU.png
Here is my plugin list: http://i.imgur.com/GBA0qgY.png
And here is a "Measure" report from "about:memory" : http://privatepaste.com/bcd17c1093
I just want to know why it leaks so badly, almost the double RAM it would normally use.
Currently i'm like 3 tabs with 1.25 GB (Private Set) used, when i close a few tabs, it keeps stable or even rising by a few mb.
I hope there's something useful with that report/my extensions|plugins.
Thanks for the reading.I heard about that extension "problem" but, when i see on "about:addons-memory" from a third-party extension (that i can't remember but yo can see it in the link on OP, it only uses few megabytes (20~) , so, either it's a memory leak on the extension (if that's really the cause) a problem with my addon to view the extensions memory or a firefox one.
But i seriously don't expect that extension eats up all of this memory, but i will test it in a couple of days. -
My company has made the decision to do all of our internal inter-system communication using XML. Often we may need to transfer thousands of records from one system to another and due to this (and the 32K limit in prior versions) we're implementing it in 11g. Currently we have Oracle 11g Enterprise Edition Release 11.1.0.6.0 on 64 bit Linux.
This is a completely network/memory setup - the XML data comes in using UTL_HTTP and is stored in a CLOB in memory and then converted to a DOMDocument variable and finally the relevant data is extracted using xslprocessor.valueof calls.
While this is working fine for smaller datasets, I've discovered that repeated calls with very large documents cause the xslprocessor to run out of memory with the following message:
ERROR at line 1:
ORA-04030: out of process memory when trying to allocate 21256 bytes
(qmxdContextEnc,)
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 1010
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 1036
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 1044
ORA-06512: at "SCOTT.UTL_INTERFACE_PKG", line 206
ORA-06512: at line 28
Elapsed: 00:03:32.45
SQL>
From further testing, it appears that the failure occurs after approximately 161,500 calls to xslprocessor.valueof however I'm sure this is dependent on the amount of server memory available (6 GB in my case).
I expect that we will try and log a TAR on this, but my DBA is on vacation right now. Has anyone else tried calling the xslprocessor 200,000 times in a single session?
I've tried to make my test code as simple as possible in order to track down the problem. This first block simply iterates through all of our offices asking for all of the employees at that office (there are 140 offices in the table).
DECLARE
CURSOR c_offices IS
SELECT office_id
FROM offices
ORDER BY office_id;
r_offices C_OFFICES%ROWTYPE;
BEGIN
OPEN c_offices;
LOOP
FETCH c_offices INTO r_offices;
EXIT WHEN c_offices%NOTFOUND;
utl_interface_pkg.get_employees(r_offices.office_id);
END LOOP;
CLOSE c_offices;
END;
Normally I'd be returning a collection of result data from this procedure, however I'm trying to make things as simple as possible and make sure I'm not causing the memory leak myself.
Below is what makes the SOAP calls (using the widely circulated UTL_SOAP_API) to get our data and then extracts the relevant parts. Each office (call) should return between 200 and 1200 employee records.
PROCEDURE get_employees (p_office_id IN VARCHAR2)
l_request utl_soap_api.t_request;
l_response utl_soap_api.t_response;
l_data_clob CLOB;
l_xml_namespace VARCHAR2(100) := 'xmlns="' || G_XMLNS_PREFIX || 'EMP.wsGetEmployees"';
l_xml_doc xmldom.DOMDocument;
l_node_list xmldom.DOMNodeList;
l_node xmldom.DOMNode;
parser xmlparser.Parser;
l_emp_id NUMBER;
l_emp_first_name VARCHAR2(100);
l_emp_last_name VARCHAR2(100);
BEGIN
--Set our authentication information.
utl_soap_api.set_proxy_authentication(p_username => G_AUTH_USER, p_password => G_AUTH_PASS);
l_request := utl_soap_api.new_request(p_method => 'wsGetEmployees',
p_namespace => l_xml_namespace);
utl_soap_api.add_parameter(p_request => l_request,
p_name => 'officeId',
p_type => 'xsd:string',
p_value => p_office_id);
l_response := utl_soap_api.invoke(p_request => l_request,
p_url => G_SOAP_URL,
p_action => 'wsGetEmployees');
dbms_lob.createtemporary(l_data_clob, cache=>FALSE);
l_data_clob := utl_soap_api.get_return_clob_value(p_response => l_response,
p_name => '*',
p_namespace => l_xml_namespace);
l_data_clob := DBMS_XMLGEN.CONVERT(l_data_clob, 1); --Storing in CLOB converted symbols (<">) into escaped values (<, &qt;, >). We need to CONVERT them back.
parser := xmlparser.newParser;
xmlparser.parseClob(parser, l_data_clob);
dbms_lob.freetemporary(l_data_clob);
l_xml_doc := xmlparser.getDocument(parser);
xmlparser.freeparser(parser);
l_node_list := xslprocessor.selectNodes(xmldom.makeNode(l_xml_doc),'/employees/employee');
FOR i_emp IN 0 .. (xmldom.getLength(l_node_list) - 1)
LOOP
l_node := xmldom.item(l_node_list, i_emp);
l_emp_id := dbms_xslprocessor.valueOf(l_node, 'EMPLOYEEID');
l_emp_first_name := dbms_xslprocessor.valueOf(l_node, 'FIRSTNAME');
l_emp_last_name := dbms_xslprocessor.valueOf(l_node, 'LASTNAME');
END LOOP;
xmldom.freeDocument(l_xml_doc);
END get_employees;
All of this works just fine for smaller result sets, or fewer iterations (only the first two or three offices). Even up to the point of failure the data is being extracted correctly - it just eventually runs out of memory. Is there any way to free up the xslprocessor? I've even tried issuing DBMS_SESSION.FREE_UNUSED_USER_MEMORY but it makes no difference.Replying to both of you -
Line 206 is the first call to xslprocessor.valueof:
LINE TEXT
206 l_emp_id := dbms_xslprocessor.valueOf(l_node, 'EMPLOYEEID');
This is one function inside of a larger package (the UTL_INTERFACE_PKG). The package is just a grouping of these functions - one for each type of SOAP interface we're using. None of the others exhibited this problem, but then none of them return anywhere near this much data either.
Here is the contents of V$TEMPORARY_LOBS immediately after the crash:
SID CACHE_LOBS NOCACHE_LOBS ABSTRACT_LOBS
132 0 0 0
148 19 1 0
SID 132 is a SYS session and SID 148 is mine.
I've discovered with further testing that if I comment out all of the xslprocessor.valueof calls except for the first one the code will complete successfully. It executes the valueof call 99,463 times. If I then uncomment one of those additional calls, we double the number of executions to a theoretical 198,926 (which is greater than the 161,500 point where it usually crashes) and it runs out of memory again. -
JBoss EAP 6 On JRockit - Memory Leak
hello team.
I have memory leak problem on jboss and jrockit.
My Environment :
1. OS :
CentOS release 6.4 (Final)
2. JRockit :
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Oracle JRockit(R) (build R28.2.7-7-155314-1.6.0_45-20130329-0641-linux-x86_64, compiled mode)
3. Application Server:
JBoss EAP 6.2.0.GA
4. Application
Large EJB Application (100 and more EJB Beans (Stateless, Stateful, MDB, Timers and so on)
Everything works fine on older application server versions (4.3 , 4.2)
But now I have Problem
Of course I know that problem is new version - and i have discussion on JBoss forums.
but guys I have question about jrockit with you:
What is the option "Other" in memory ??
[jboss@jboss-new bin]$ jrcmd 17114 print_memusage
17114:
Total mapped 8457864KB (reserved=2983100KB)
- Java heap 3145728KB (reserved=0KB)
- GC tables 105232KB
- Thread stacks 46412KB (#threads=138)
- Compiled code 1048576KB (used=12257KB)
- Internal 1480KB
- OS 170324KB
- Other 3639056KB
- Classblocks 10496KB (malloced=9631KB #28393)
- Java class data 289536KB (malloced=192391KB #133697 in 28393 classes)
- Native memory tracking 1024KB (malloced=294KB #10)
[jboss@jboss-new bin]$
This size increases every time - and took entire amount of RAM.
Thank in Advance.
Regards,
Paata LominadzeNot sure what the 'other' is, but it is probably best shown by using an example. By using displayMap we can display a memory map of various JVM subsystems and libraries that are loaded, including third-party libraries.
./jrcmd 4523 print_memusage displayMap
Total mapped 3984796KB (reserved=2978740KB)
- Java heap 524288KB (reserved=0KB)
- GC tables 17548KB
- Thread stacks 20276KB (#threads=39)
- Compiled code 1048576KB (used=14224KB)
- Internal 1672KB
- OS 146924KB
- Other 2092648KB
- Classblocks 7424KB (malloced=7381KB #20064)
- Java class data 124416KB (malloced=124411KB #91048 in 20064 classes)
- Native memory tracking 1024KB (malloced=118KB #10)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
OS *java r x 0x0000000000400000.( 76KB)
OS *java rw 0x0000000000612000.( 4KB)
OS *[heap] rw 0x00000000007c1000.( 132KB)
INT Poll r 0x000000007fffe000 ( 4KB)
INT Membar rw 0x000000007ffff000.( 4KB)
MSP Classblocks (1/2) rw 0x00000000df8c0000 ( 6912KB)
MSP Classblocks (2/2) rw 0x00000000dff80000 ( 512KB)
HEAP Java heap rw 0x00000000e0000000.( 524288KB)
OS *ld-2.12.so r x 0x0000003664400000.( 128KB)
OS *ld-2.12.so r 0x000000366461f000 ( 4KB)
OS *ld-2.12.so rw 0x0000003664620000 ( 4KB)
OS **ld-2.12.so rw 0x0000003664621000.( 4KB)
OS *gconv-modules.cache r 0x00007f8f2e4a0000 ( 28KB)
THREAD Stack 4630 rwx 0x00007f8f2e4a7000 ( 8KB)
THREAD Stack 4630 0x00007f8f2e4a9000 ( 12KB)
THREAD Stack 4630 rwx 0x00007f8f2e4ac000 ( 244KB)
MSP Java class data (5/37) rw 0x00007f8f2e4e9000 ( 14336KB)
MSP Java class data (9/37) rw 0x00007f8f2fa40000 ( 5888KB)
rw 0x00007f8f30000000 ( 188KB)
0x00007f8f3002f000 ( 65348KB)
rw 0x00007f8f34000000 ( 132KB)
0x00007f8f34021000 ( 65404KB)
rw 0x00007f8f38000000 ( 412KB)
0x00007f8f38067000.( 65124KB)
MSP Java class data (10/37) rw 0x00007f8f3c034000 ( 34048KB)
rw 0x00007f8f3e174000 ( 8200KB)
MSP Java class data (11/37) rw 0x00007f8f3e976000 ( 256KB)
OS *libhpi.so rw 0x00007f8fb37fc000 ( 8KB)
OS **libhpi.so rw 0x00007f8fb37fe000 ( 4KB)
CODE Compiled code rwx 0x00007f8fb37ff000 ( 64KB)
CODE Compiled code rwx 0x00007f8fb380f000 ( 128KB)
CODE Compiled code rwx 0x00007f8fb382f000 ( 64KB)
MSP Java class data (37/37) rw 0x00007f8ff83a1000 ( 512KB)
GC Modified Union Set (committed) rw 0x00007f8ff8421000 ( 132KB)
GC Card table rw 0x00007f8ff8442000 ( 1024KB)
GC Object bits (committed) rw 0x00007f8ff8542000 ( 8196KB)
Here
- thread is thread related (such as thread stacks)
- int, internal use (such as pointer pages)
- heap, chunk used by JRockit for the Java heap
- os, mapped directly from the operating system, such as third party DLLs or shared objects
- msp, memory space. a memory space is a native heap with a specific purpose, for example native memory allocation inside the JVM
- gc, garbage collection related, for example live bits
- code, compiled code
The 'other' memory space looks to me (from the blank entries in the above print-out) like they are a memory pages to are still not used. When the JVM starts it mappes an amount of memory. To my knowledge JRockit uses mmap (mmap(2) - Linux manual page), which creates a new mapping in the virtual address space. JRockit reserves an amount of memory (Java Heap (heap where your object instances go) + its own runtime (all the others)).
To see where the growth is in the various memory spaces, you can use 'print_memusage baseline', after which you can execute print_memusage again, for example,
./jrcmd 4523 print_memusage scale=M
4523:
Total mapped 3896MB +4MB (reserved=2905MB -3MB)
- Java heap 512MB (reserved=0MB)
- GC tables 17MB
- Thread stacks 19MB (#threads=39)
- Compiled code 1024MB (used=14MB +1MB)
- Internal 1MB
- OS 143MB
- Other 2043MB
- Classblocks 7MB (malloced=7MB #20596 +532)
- Java class data 126MB +4MB (malloced=125MB +4MB #93640 +2592 in 20596 classes)
- Native memory tracking 1MB (malloced=0MB #20 +10)
Note the additional column that prints out the difference in memory usage in relation to the baseline. You can also monitor native allocations by using trace_alloc_sites, memory allocations can then be displayed with different levels of detail using the level argument.
./jrcmd 4523 print_memusage trace_alloc_sites=true
4523:
Total mapped 3989660KB +4864KB (reserved=2974732KB -4008KB)
- Java heap 524288KB (reserved=0KB)
- GC tables 17548KB
- Thread stacks 20276KB (#threads=39)
- Compiled code 1048576KB (used=15265KB +1040KB)
- Internal 1672KB
- OS 146924KB
- Other 2092648KB
- Classblocks 7680KB +256KB (malloced=7669KB +287KB #20596 +532)
- Java class data 129024KB +4608KB (malloced=128967KB +4555KB #93640 +2592 in 20596 classes)
- Native memory tracking 1024KB (malloced=236KB +118KB #20 +10)
./jrcmd 4523 print_memusage level=3
4523:
Total mapped 3989660KB +4864KB (reserved=2974732KB -4008KB)
- Java heap 524288KB (reserved=0KB)
- GC tables 17548KB
- Thread stacks 20276KB (#threads=39)
- Compiled code 1048576KB (used=15265KB +1040KB)
- Internal 1672KB
- OS 146924KB
- Other 2092648KB
- Classblocks 7680KB +256KB (malloced=2KB -7379KB #4 -20060) Not fully traced
- Java class data 129024KB +4608KB (malloced=26KB -124385KB #16 -91032 in 20596 classes) Not fully traced.
- Native memory tracking 1024KB (malloced=118KB #10) Not fully traced.
gather_memorymap_database memtrace.c: 206 91KB +91KB (#1 +1)
gather_memory_usage osal_mspace.c:5142 7KB +7KB (#4 +4)
msGatherMSpacesUsageDatabase osal_mspace.c:6128 2KB +2KB (#1 +1)
msGatherMSpacesUsageDatabase osal_mspace.c:6134 16KB +16KB (#1 +1)
Note this is more on the JVM level, in your case in might be beneficial to investigate what is happening on the java heap. By using print_object_summary you can get insight how memory on the heap is used on a per-class basis. To get to the bottom of where the memory leak is you can use the memory-leak-detector (an example of its use can be found here Middleware Snippets: Fast, Faster, JRockit). You can also obtain a heapdump that can be analyzed by using for example MAT (see for an example here Middleware Snippets: Visualizing Class Loading). To obtain a heapdump you can run the command, for example,
[weblogic@machine1 bin]$ ./jrcmd 4523 runsystemgc full=true fullcompact=true
4523:
[weblogic@machine1 bin]$ ./jrcmd 4523 hprofdump filename=/home/weblogic/dump.hprof
4523:
Wrote dump to /home/weblogic/dump.hprof
Note that this first issues a full GC by using the runsystemgc command. -
Memory Leak Issue in OBIEE 11g
Hi,
We have OBIEE 11.1.1.5 installed on a 32-bit Windows Server. We had almost 10GB of free space yesterday, but after a few users logged in, the free space started coming down until we were left with no space at all.
Since then we have removed all the files that we could and created more and more space, but OBIEE seems to be eating it all up. I have seen a few posts for such issues with the Linux Systems. Has anyone faced this with windows? Also, is there any solution for this.
Thanks,
NamanHi Naman,
Oracle has provided set of patches to avoid memory leaks.
1) For memory leak with OPMN, apply the following patches:
Patch:12920592: OPMN HAS MEMORY LEAK
Patch:12989751: OPMN MEMORY STILL GAINS AFTER APPLYING PATCH#12920592
2) For the Presentation Server (sawserver) issue, apply the patch:
Patch:13102881: DATALAYOUT METADATA IMPLEMENTATION HEAP INTENSIVE
Rgds,
Dpka -
HTTPService + XML Load + Memory Leak
Hi all....
I have noticed a memory leak in my application. This leak was
not apparent when the application was completed some months back
which is what left me a little confused as all I have done since
was upgrade to Flex 3 and possibly updated / changed my Flash
player.
I think I have found the cause to this problem (below) but am
not 100% sure that it is the "actual" problem or any reasons to
back my thoughts up, so have listed what I have checked / tried
along the way (maybe I have missed something)....
My Discovery Process:
I started profiling my application but did not find anything
out of the ordinary. I did a code walk-through double checking I
had cleaned up after myself, removing and even nulling all items
etc but still to now success - the leak is still there.
I have profiled the app in the profiler for reasonably long
periods of time.
All the classes etc being used within the app are consistent
in size and instance amount and there is no sign of any apparent
leak.
I am using a HTTPService that is loading XML data which I am
refreshing every 5 seconds. On this 5 second data refresh some
class instances are incremented but are restored to the expected
amount after a GC has occurred. The GC seems to take longer, the
longer the app is running, therefore more and more instances are
being added to the app, but when the GC eventually runs it "seems"
to clear these instances to the expected amount.
After scratching my head for a while I decided to make a copy
of my application, rip everything out, and focus in my data load,
where I found a problem!
I have now just a HTTPService that loads an XML file every 5
seconds, and this is all I currently have in the app (as I ripped
the rest of the code out), e.g:
Code:
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
....... creationComplete="initApp()" >
<mx:HTTPService
id="httpServiceResults"
url="
http://myIP:myPort/myRoot/myXML.cfm"
resultFormat="e4x"
result="httpResultHandler(event)" />
<script....... >
private var timerPulse:Timer;
private function initApp():void
httpServiceResults.send();
timerPulse = new Timer(5000, 0);
private function httpResultHandler(event:ResultEvent):void
timerPulse.start();
timerPulse.addEventListener(TimerEvent.TIMER, timerRefresh);
public function timerRefresh(eventObj:TimerEvent):void
timerPulse.stop();
timerPulse.removeEventListener(TimerEvent.TIMER,
timerRefresh);
timerPulse.reset();
httpServiceResults.send();
</script>
</mx:Application>
This is pretty much the code I am currently using and it
leaks.
I ran and monitored this in both the profiler and the
activity / task manager, and after running the app for 1800 seconds
(30 min) in the profiler, the memory size grew from 50mg to 165mg
just sending the HTTPService.
I tried loading the service in multiple ways including in AS
rather than MXML creating new instances of it each time, resetting
it, nulling it etc... but nothing prevented this memory increase.
I then tried to load the XML using different methods such as
using the URLRequest and URLLoader which again caused a memory
leak.
What still confuses me is that this leak did not exist in the
previous version and not a great deal has changed since then apart
from upgrading to Flex 3 and possibly upgrading my Flash payer
(which I believe is a possible cause)
After looking into this issue a bit more deeply, I read a few
blogs / forums and other people are experiencing the same problems
- even with a lot bigger leaks in some cases all when reloading
large sets of XML data into Flex - however, I as of yet found no
solution to this leak - people with a similar problem believe it is
not due to a memory leak more a GC error, and others pointing
towards the Flash Player itself that is leaking - I don't really
know.
Findings so far during investigation of this issue:
* App leaks for both HTTPService and ULRRequest / URLLoader
methods
* App only leaks when calling a data loader
* The size of the leak seems to depend on the size of the
XML being loaded
* The size of the leak also seems to be affected by the
applications heaviness - the greater seems to enhance the leak
An interesting factor I have noticed is that if I copy the
XML from my "myXML.cfm" that I link to in my HTTPService and copy
the contents of the file into my own XML file stored within the
Flex project root itself: ""myXML.xml"" the leak disappears... like
it seems to link when loading the XML over a network, however as my
network knowledge is not great I am not sure what to make of this -
any ideas???
Could the connection to the XML document cause leaks??? is
there anything else that could cause this leak??? have I something
in my code sample that could cause this leak??? or could any of the
other things I have mentioed cause this leak???
Any help / ideas would be greatly appreciated.
Thanks,
Jon.I also observed heavy memory leak from using httpservice with
XML data. I am using Flex3 builder under Linux. My Flex application
polls httpservice every 10 seconds. The reply is a short XML
message less than 100 bytes. This simple polling will consume 30+
MB of memory every hour. I leave it idling for several hours and it
took 200 MB of memory. No sign of garbage collection at all. -
Memory leak in WLS6.1 sp3 on Solaris?
We are running WLS 6.1 sp3 on Solaris 8 using Sun's 1.3.1 JVM with BEA's
JDriver to connect to Oracle (8.1.7). We have set the JVM to a maximum heap
of 512M (-Xms256m -Xmx512m).
The issue is that we are now seeing (via pmap) the resident memory growing
to ~1GB. Yet, the WLS management console is reporting memory usage of ~200M.
So, if we are to believe WLS, then the JVM (or some native library) is
chewing up the extra memory.
Having examined the results of "pmap -x <pid>", I see the heap (and some
anon) mem/file are quite large.
Address Kbytes Resident Shared Private Permissions Mapped File
00026000 418912 416096 - 416096 read/write/exec [ heap ]
D8C00000 524288 447928 - 447928 read/write/exec [ anon ]
total Kb 1083832 981136 37960 943176
Questions:
- Are there any known memory leaks with 6.1 sp3 on Solaris?
- Should it be possible for pmap's value of "heap" to grow larger than the
"Xms" setting? We have observed this recently, but the numbers above don't
reflect this.
- Any idea what the "anon" is or how to determine what it is?
- Do you know of any tools that might help me determine what is using that
memory or what is in it?
Any suggestions will be greatly appreciated...
Thanks in advance,
ErikIf you set -Xmx512m then the java heap will grow no larger than 512MB.
WLS is reporting the size of the java heap. (It is a java program after
all and doesn't know a lot about what native code might be doing.)
My first thought is try running with Oracle's thin (type-4) driver.
Since this is java code, it will use the java heap. If the memory usage
drastically changes, then you can point the finger at the jDriver.
Are you using any other native code / libraries?
-- Rob
Erik Westland wrote:
We are running WLS 6.1 sp3 on Solaris 8 using Sun's 1.3.1 JVM with BEA's
JDriver to connect to Oracle (8.1.7). We have set the JVM to a maximum
heap
of 512M (-Xms256m -Xmx512m).
The issue is that we are now seeing (via pmap) the resident memory growing
to ~1GB. Yet, the WLS management console is reporting memory usage of
~200M.
So, if we are to believe WLS, then the JVM (or some native library) is
chewing up the extra memory.
Having examined the results of "pmap -x ", I see the heap (and some
anon) mem/file are quite large.
Address Kbytes Resident Shared Private Permissions Mapped File
00026000 418912 416096 - 416096 read/write/exec [ heap ]
D8C00000 524288 447928 - 447928 read/write/exec [ anon ]
total Kb 1083832 981136 37960 943176
Questions:
- Are there any known memory leaks with 6.1 sp3 on Solaris?
- Should it be possible for pmap's value of "heap" to grow larger than the
"Xms" setting? We have observed this recently, but the numbers above don't
reflect this.
- Any idea what the "anon" is or how to determine what it is?
- Do you know of any tools that might help me determine what is using that
memory or what is in it?
Any suggestions will be greatly appreciated...
Thanks in advance,
Erik -
Memory leak in Tomcat 5.5
Hi all, i am experiencing memory leaks while using tomcat 5.5 and mysql connector 3.1.7.. While running the attached code tomcat swallows up to 20 mb and doesnt return it. I close down everything but the app still leaks mem. For now it's not an issue (Tomcat stays below 60mb mem of 1gb), however running this app on serveral clients will dramatically increase the memory allocation.
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
public class Thumbs extends HttpServlet {
private String dbDriver = "com.mysql.jdbc.Driver";
private String dbURL = "jdbc:mysql://localhost/webapp?";
private String userID = "javauser";
private String passwd = "javadude";
private Connection dbConnection;
//Initialize global variables
public void init() throws ServletException {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
String maxDim = "";
String siteString = request.getParameterValues("s")[0];
if (request.getParameterValues("d") != null){
maxDim = request.getParameterValues("d")[0];
if (maxDim == ""){
response.setContentType("image/jpeg");
OutputStream out = response.getOutputStream();
writePicture(out,siteString);
else{
if (siteString != null) {
int maxDimension = Integer.parseInt(maxDim);
response.setContentType("image/jpeg");
OutputStream out = response.getOutputStream();
writeThumbnailPicture(out, siteString, maxDimension);
} catch (Exception ex){
ex.printStackTrace();
log(ex.getMessage());
public void writePicture(OutputStream out, String siteID){
try{
Class.forName(dbDriver);
dbConnection = DriverManager.getConnection(dbURL, userID, passwd);
PreparedStatement stmt = dbConnection.prepareStatement("select * from webcatalog where ID = ?");
stmt.setString(1,siteID);
stmt.executeQuery();
ResultSet rs = stmt.getResultSet();
if (rs.next()) {
byte[] data = rs.getBytes("Picture");
if (data != null) {
Image inImage = new ImageIcon(data).getImage();
BufferedImage outImage = new BufferedImage(inImage.getWidth(null),
inImage.getHeight(null),
BufferedImage.TYPE_INT_RGB);
// Paint image.
Graphics2D g2d = outImage.createGraphics();
g2d.drawImage(inImage,null,null);
// JPEG-encode the image
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(outImage);
out.close();
rs.close();
stmt.close();
dbConnection.close();
}catch(Exception ex){
ex.printStackTrace();
public void writeThumbnailPicture(OutputStream out,String siteID,int maxDimension){
try{
Class.forName(dbDriver);
dbConnection = DriverManager.getConnection(dbURL, userID, passwd);
PreparedStatement stmt = dbConnection.prepareStatement("select * from webcatalog where ID = ?");
stmt.setString(1,siteID);
stmt.executeQuery();
ResultSet rs = stmt.getResultSet();
if (rs.next()) {
byte[] data = rs.getBytes("Picture");
if (data != null) {
Image inImage = new ImageIcon(data).getImage();
// Determine the scale.
double scale = (double)maxDimension / (double)inImage.getHeight(null);
if (inImage.getWidth(null) > inImage.getHeight(null)) {
scale = (double)maxDimension /(double)inImage.getWidth(null);
// Determine size of new image.
// One of them should equal maxDim.
int scaledW = (int)(scale*inImage.getWidth(null));
int scaledH = (int)(scale*inImage.getHeight(null));
// Create an image buffer in
//which to paint on.
BufferedImage outImage = new BufferedImage(scaledW, scaledH,
BufferedImage.TYPE_INT_RGB);
// Set the scale.
AffineTransform tx = new AffineTransform();
// If the image is smaller than
// the desired image size,
// don't bother scaling.
if (scale < 1.0d) {
tx.scale(scale, scale);
// Paint image.
Graphics2D g2d = outImage.createGraphics();
g2d.drawImage(inImage, tx, null);
g2d.dispose();
// JPEG-encode the image
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(outImage);
out.close();
rs.close();
stmt.close();
dbConnection.close();
catch(Exception ex){
ex.printStackTrace();
//Clean up resources
public void destroy() {
private void jbInit() throws Exception {
}you can try this:
open your connection outside the function, and then pass it like as a parameter...
writePicture(OutputStream out, String siteID, Connection conn)
this can solve the problem because opening the connection inside the function spends a lot of memory...
Hope this can help you
Regards
Fernando -
Memory leak in Jain-SIP ?
Hi there.
We implemented a SIP gateway to MS OCS 2007 using
Jain-SIP version 1.2.1906.
One problem we have is memory consumption.
Using jconsole we found out that memory is not
completely released when SIP clients log out.
E.g. the following classes keep on accumulating:
53134 instances of class gov.nist.core.NameValueList
41730 instances of class gov.nist.core.NameValue
20330 instances of class gov.nist.core.Host
20330 instances of class gov.nist.core.HostPort
19767 instances of class gov.nist.core.DuplicateNameValueList
19767 instances of class gov.nist.core.MultiValueMapImpl
16162 instances of class gov.nist.javax.sip.address.Authority
16162 instances of class gov.nist.javax.sip.address.SipUri
13570 instances of class gov.nist.javax.sip.address.UserInfo
12261 instances of class gov.nist.javax.sip.address.AddressImpl
5210 instances of class gov.nist.javax.sip.header.Protocol
5210 instances of class gov.nist.javax.sip.header.Via
4168 instances of class gov.nist.javax.sip.header.CallID
4168 instances of class gov.nist.javax.sip.header.CallIdentifier
3901 instances of class gov.nist.javax.sip.header.CSeq
3901 instances of class gov.nist.javax.sip.header.ContentLength
3901 instances of class gov.nist.javax.sip.header.From
3901 instances of class gov.nist.javax.sip.header.MaxForwards
3901 instances of class gov.nist.javax.sip.header.RequestLine
3901 instances of class gov.nist.javax.sip.header.To
3901 instances of class gov.nist.javax.sip.header.ViaList
3901 instances of class gov.nist.javax.sip.message.SIPRequest
3901 instances of class gov.nist.javax.sip.stack.SIPTransaction$TransactionSemaphore
2858 instances of class gov.nist.javax.sip.DialogFilter
2618 instances of class gov.nist.javax.sip.header.Route
2618 instances of class gov.nist.javax.sip.header.RouteList
2592 instances of class gov.nist.javax.sip.stack.SIPServerTransaction
2590 instances of class gov.nist.javax.sip.header.ContentDisposition
2590 instances of class gov.nist.javax.sip.header.ContentType
2590 instances of class gov.nist.javax.sip.header.MediaRange
1579 instances of class org.apache.xmlbeans.SchemaType$Ref
1309 instances of class gov.nist.javax.sip.header.UserAgent
1309 instances of class gov.nist.javax.sip.parser.Pipeline
1309 instances of class gov.nist.javax.sip.parser.PipelinedMsgParser
1309 instances of class gov.nist.javax.sip.parser.StringMsgParser
1309 instances of class gov.nist.javax.sip.stack.HopImpl
1309 instances of class gov.nist.javax.sip.stack.SIPClientTransaction
1309 instances of class gov.nist.javax.sip.stack.SIPClientTransaction$TransactionTimer
1309 instances of class gov.nist.javax.sip.stack.SIPDialog
These all are classes from the SIP stack aren't they ?
Are there any known issues with memory leaks
in Jain-SIP ?
Is it probably a configuration issue with
the properties/parameters for the SIP stack ?
(There is a property gov.nist.javax.sip.AGGRESSIVE_CLEANUP which we set
to TRUE but it didn't help)
Do we miss to release/initialize anything in the SIP stack manually ?
Thanks a lot in advance,
FredNobody else seems ton have this problem. I haven't run my SIP code for as long as a week at a time but i didn't notice any undue memory usage, and I also trawled inside the source a lot without seeing anything odd. So is it your code leaking? Are you sure you're releasing everything to do with a conversation when it ends? Rather than say accumulating things in some static data structure?
Maybe you are looking for
-
I am able to connect to my Mac Mini on Back to My Mac through iCloud but the keyboard/trackpad on the MBAir or MBP with which I access does not register on the Mini. So I can see the screen but cannot interact with it. Mini works accessing MBP/Air a
-
I have two personal iTunes accounts and want to conjoin the into one so that I can sync my contents to my iPhone4. So far I can only figure out how to sync with the iTunes account that I have obligated to my iPhone. CAn I conjoin the two accounts so
-
Ides ecc customization.
Im in the process of installing IDES ECC 5.0 evaluation copy. Can anyone advice me how to customize this installation so I can perform the assignments in the SAP HR academy study material. I need to have a company code called CABB within the ECC in
-
Why does it say missing plugin when i try to watch a video or play an online game
While i'm in safari and i try to watch certain videos or play online games it says missing plug-in
-
My work shifts often span midnight. If I enter an event spannng midnight in iCal on my iMac, it shows up on my iPod as two events, both with the same start and finish times, but on successive days, the day of the event itself and the day afterwards.