Macintosh: Java Application Development

Printer-friendly version

This appendix gives platform-specific details about developing Objectivity for Java applications on a Macintosh platform. You should use this appendix in conjunction with the Objectivity for Java programmer’s guide.

This appendix provides information about:

Note: If you want to learn how to use various Objectivity for Java features, consider downloading and running some of the sample Java applications.

Application Programming Issues

File-Descriptor Limit

When running multithreaded programs with large numbers of threads, your process may reach the file-descriptor limit. When this limit is reached, the Java virtual machine unloads classes, and, at a later time, may report that it cannot find the definition of a class. Alternatively, Objectivity for Java operations may fail, with the cause being the inability to obtain a file descriptor.

To eliminate these errors, you should increase the file-descriptor limit. The bash and csh commands to increase the limit are shown below. If you still experience errors, you should increase the limit incrementally.


ulimit -n 256 


limit descriptors 256

Finalizing Objects in JDK

If you are developing an Objectivity for Java application, you should be aware of the following JDK defect reported in the Sun Developer Network bug database:

Java objects created in JNI using AllocObject are not finalized

This defect affects your application if any of your persistence-capable classes defines a finalize() method.

The workaround is to add a default constructor that simply creates an empty object of the class.


public class PCclass extends ooObj { 
  // If this exists...
  protected void finalize() {
  // ... you must add this...
  public PCclass() { // Construct a dataless object

Signal Handling

The Objectivity/DB predefined signal handler is not available on the Macintosh platform because the Macintosh Java runtime environment does not support signal chaining.

Java Command Line Options

Stack Size

The default maximum native stack size allocated by the Java virtual machine for any thread (including the main thread) is platform-specific. In general, these default values are inadequate for Objectivity for Java. An inadequate stack size may cause an Objectivity for Java application to terminate with a segmentation violation for no apparent reason.

You change the default thread stack size for the Java virtual machine with the option:



size Number of bytes. To specify kilobytes or megabytes, append size with k or m, respectively.


To specify a stack size of 2 megabytes:

% java -Xss2m classname 

Memory Requirements

If an Objectivity for Java application encounters java.lang.OutOfMemory errors, you can increase the amount of memory for the Java virtual machine with either or both of the following options:

-Xmssize Sets the initial memory size.
-Xmxsize Sets the maximum memory size.


size Number of bytes. To specify kilobytes or megabytes, append size with k or m, respectively.


Monday, August 20, 2012