Win a copy of Terraform in Action this week in the Cloud forum!

Steven Ostrowski

Greenhorn
+ Follow
since Jul 31, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steven Ostrowski

I installed JProfiler 4.0.2 on a Windows Server 2003 machine. I'm integrating to a JBoss 3.2.5 application server session.

When I startup the session with JProfiler, it connects to the port. However, it then freezes after it says :

"
JProfiler> Waiting for a connection from the JProfiler GUI ...
JProfiler> Using dynamic instrumentation Time measurement: elapsed
JProfiler> time CPU profiling enabled
"

It does not proceed to starting Java like it should. This works fine on my development machine, but when I use it on the production machine it hangs like this.

I've tried toggling all the switches (e.g. hotspot vs. interpreted mode, JDK vs. JRE, etc).

The production machine has a 4-way CPU, I'm wondering if that has anything to do with it?
Sure enough, this turned out to be one of our developers not closing ResultSet and PreparedStatement. They have since been fired (j/k).
btw - I tried this out with the Oracle 10g drivers as well, which are a very different implementation of the JDBC driver.

The screenshot of the new heap dumps are interesting in that it looks more like a deep recursion issue now:

http://www.dealraider.com/heapDump10a.jpg
http://www.dealraider.com/heapDump10b.jpg

I still haven't gotten a good definition anywhere of what JVMPI_GC_ROOT_MONITOR_USED means. However, like another poster said, it does seem to appear that this is an object the GC believes cannot be garbage collected. I've verified with -verbosegc on that even after a full GC, these objects do not get deleted.

Thanks

Originally posted by Rene Smith:
The code looks good to me. The only thing you could do is set the obj = null, rs = null, statement = null, and connection = null at the end. I don't thing any of those would cause a memory leak though....



Yep, tried that, didn't do anything. I also think the GC is guaranteed to run before you get an OutOfMemoryError anyway.
Here's generally what is happening:

In JBoss, I have a datasource file:
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/MyDS</jndi-name>
...


Then, I have my connection retrieval code in its own class that is used to start a transaction:
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:/jdbc/MyDS"));
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
...
return conn;

Then, the code that uses the connection:

>>> builds up SQL statement by appending clauses into a StringBuffer
...
buffer.append("SELECT ...?..?.");
...

>>> prepares statement, and sets values, etc.
...
PreparedStatement stmt = conn.prepareStatement(buffer.toString());
...
ResultSet rs = stmt.executeQuery();

while (rs.next()) {
MyObject obj = new MyObject();
obj.setX(rs.getString("X"));
...
aList.add(obj);
}

finally {
rs.close();
stmt.close();
}



Then, when I end the transaction:
...
conn.commit();
conn.close();
...





Hope that is enough snippets for you! =)
Hello,

I'm experiencing OutOfMemoryError in my application, and it's almost always caused by calling one query too many times. For some reason, the statements executed by that query do not get garbage collected. Note: it is not one instance of this query that causes OutOfMemoryError, it is a memory leak that builds up until the application runs out of memory.

Here's the setup:
- using JBoss connection pooling with Oracle oracle.jdbc.OracleDriver
- default statement cache size
- non-scrollable and non-updatable result sets
- standard query access: build the statement, execute the statement, create a new object, populate the object with data that is retrieved from the result set, close the result set, close the statement, release the connection

I've tried many things to narrow down the cause, none of which changed the problem:
- reverted to my custom connection pooling (this ruled out JBoss connection pooling as the cause)
- set the statement cache size to 0 (this ruled out statement caching as the cause)
- verified that the result sets are non-scrollable and non-updatable (this ruled out Oracle caching large amounts of data on the client)

I've posted a screenshot of a heap dump that shows the object allocation here:

Heap Dump Screenshot

I do not know what the JVMPI_GC_ROOT_MONITOR_USED means, but others have mentioned that it probably means the GC thinks these objects are definitely referenced, so it will not garbage collect them. I've verified that other queries in my application do not cause this memory leak.

Any help would be greatly appreciated!

Originally posted by Chantal Ackermann:
hi,
I think it should work if you make sure that the url contains an exclamation mark after the jar file:
/path/jarfile!/pathinjar
However, I had the same problem some time ago, and I didn't think of trying to use ! in the path. instead, I am using another method from the class loader:
classLoder.getResourceAsStream([path inside jar]);
as your jar is in the class path, so are your binary files. thus, the class loader can load them directly from the classpath. this works fine for me (I am loading gifs this way).
the path you give to the method is the relative path inside the jar. so a gif that is stored at the first level in the jar would have the path "mygif.gif", some file in the directory "resources" inside the jar would have the path "resources/mygif.gif".
this works for the application even if it is not started through JWS, but from an executable jar, or the classpath is accordingly.
hope this was clear
Chantal



Hi Chantal,
Thanks for the reply. I believe I can access the file fine once I know where it is, but what I'm trying to do is list the files in a directory inside the jar, not knowing the names of the files beforehand.
So far, the only thing I've found is instantiating a JarFile with the running jar, and then using the entries() method to get an Enumeration and then filtering the enumeration based on the path to those entries.
Basically, I would like to get the same feature as listFiles(FileNameFilter) that is in the File class.
19 years ago
Hello, I have a JAR file that includes some binary files that I use, organized by some directory structure.
For example, inside the directory maps, I have:
maps/texas
maps/florida
Then, inside of those directories, I have the binary files I use.
The code I use to do this is shown here:
>>>>>>>>>>>>>>>>>>>>>
String dbName = "texas";

// gets the main maps directory
URL mapsDirURL = getClass().getClassLoader().getResource("com/mystuff/maps");
System.err.println("Trying to load db from path: " + mapsDirURL.getPath());
System.err.println("Trying to load db from file: " + mapsDirURL.getFile());
File mapsDir = new File(mapsDirURL.getPath());

// get the directory of the database being used
File dbDir = new File(mapsDir.getAbsolutePath() + File.separator + dbName);

System.err.println("Database dir is: " + dbDir.getAbsolutePath());

// loop through all files in the directory and construct URLs for each
File[] names = dbDir.listFiles(new ShapeFilenameFilter());

Arrays.sort(names);
<<<<<<<<<<<<<<<<<<<<
Now, when I have the code laying out on a filesystem ( not in a JAR ), this works fine.
However, when I put it in a JAR and deploy it with WebStart, the dbDir.listFiles command returns null. Unfortunately, it does not throw an exception to say more about what it wants.
With WebStart, I have full security permissions, so there is no security exception.
I think this is a more general problem of how to list "files" from a directory in a JAR like I am doing in the non-JAR case.
I'm needing direction on this ASAP, so if you know, please comment! =)
Thanks!
19 years ago
Hello, I have a JAR file that includes some binary files that I use, organized by some directory structure.
For example, inside the directory maps, I have:
maps/texas
maps/florida
Then, inside of those directories, I have the binary files I use.
The code I use to do this is shown here:
>>>>>>>>>>>>>>>>>>>>>
String dbName = "texas";

// gets the main maps directory
URL mapsDirURL = getClass().getClassLoader().getResource("com/mystuff/maps");
System.err.println("Trying to load db from path: " + mapsDirURL.getPath());
System.err.println("Trying to load db from file: " + mapsDirURL.getFile());
File mapsDir = new File(mapsDirURL.getPath());

// get the directory of the database being used
File dbDir = new File(mapsDir.getAbsolutePath() + File.separator + dbName);

System.err.println("Database dir is: " + dbDir.getAbsolutePath());

// loop through all files in the directory and construct URLs for each
File[] names = dbDir.listFiles(new ShapeFilenameFilter());

Arrays.sort(names);
<<<<<<<<<<<<<<<<<<<<
Now, when I have the code laying out on a filesystem ( not in a JAR ), this works fine.
However, when I put it in a JAR and deploy it with WebStart, the dbDir.listFiles command returns null. Unfortunately, it does not throw an exception to say more about what it wants.
With WebStart, I have full security permissions, so there is no security exception.
I think this is a more general problem of how to list "files" from a directory in a JAR like I am doing in the non-JAR case.
I'm needing direction on this ASAP, so if you know, please comment! =)
Thanks!
19 years ago
It seems to me that javax.swing.event classes ChangeListener and ChangeEvent should be at a more general and top-level package of the Java APIs.
Before I submitted a feature request on that, I wanted to see what other people think.
Nowhere do they have any dependencies on Swing, and their functionality can apply to many different things. However, it looks bad to add an import statement of javax.swing.event when your class has nothing to do with Swing.
Agreements or disagreements?
Thanks
19 years ago
nevermind....
just remember for strncpy, it doesn't take the count of characters, it also wants the count including null terminated.
[ September 13, 2002: Message edited by: Steven Ostrowski ]
[ September 13, 2002: Message edited by: Steven Ostrowski ]
19 years ago
update: After spending a bit of time searching, I found a great driver for both Windows and Linux (and working on a mac port). It is called (excitingly) Joystick Driver for Java and is at:
http://sourceforge.net/projects/javajoystick/
Hello everyone,
I was wondering if there is a more portable joystick API and implementation than JXInput. I need to have fairly complex control with multiple axes, buttons, etc.
Thanks
[ August 26, 2002: Message edited by: Steven Ostrowski ]
19 years ago
That looks fine to me code-wise. Not sure why it would crash. I'd just re-verify that you built the shared library correctly.
You said it prints out the string but then crashes on the return? That should mean it is loading the shared library fine and finding the link fine. With such a simple function, I don't see what else could go wrong.
19 years ago
Hey everyone,
I have a tricky problem with configuration of an application that uses both jdbc and jms. In particular, the /etc/hosts file in linux. For the 127.0.0.1 address I have the aliases: localhost, localhost.localdomain, and foo (name of the machine). However, if I put foo there, I no longer receive JMS messages. That seems very strange to me. I can still connect to the j2ee server (which is running on a different machine that I have listed in the orb.properties file) however I receive no messages.
If I do not put foo as an alias for 127.0.0.1 then I do get the messages. The reason I want to put foo is because MySQL likes it better as an alias for localhost.
Why would JMS not deliver me messages (or why would me as a client be discarding them if that is the case) based on whether I have my machine name as an alias? How can I reconcile it?
Thanks
I'm not exactly sure of what you're trying to do, some code posting may help. In case you don't know, if you intermix any strings between Java and C/C++, you need to conversions between the Unicode and UTF-8 formats. Also, in some cases you will need to explicitly de-allocate strings you have created. You can read up on strings in the JNI tutorial.
BTW - on my problem, it may turn out to not be a JNI-issue. I'm checking into it.
19 years ago