Class ResourceWatcher

java.lang.Object
com.mcpdbwizard.pub.ResourceWatcher

public class ResourceWatcher extends Object
A static class for keeping track of free memory.

This class is used by ReadOnlyRowSet's caching mechanism. If the JVM appears to be running out of memory ReadOnlyRowSet will decline to add a query result to its cache. This class is problematic as some JVM's wait till the absolute last moment (i.e. no free memory left at all) before getting more memory.

Future versions of MCPDBWizard may make this class a lot smarter.

Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)

Version:
7
Author:
devteam@mcpdbwizard.com
See Also:
  • Field Details

    • MIN_SAFE_MEMORY_PCT

      public static final int MIN_SAFE_MEMORY_PCT
      Constant used to decide when we are about to run out of memory.

      We need a way of telling when we are low on memory. Most JVMs will be created with a relativly small amount of memory and will allocate more as the need arises until the limit on memory is reached. The problem is that the JVM may wait till the last moment before allocating memory. Most JVM's will have allocated all the memory they can before they get to the point where only MIN_SAFE_MEMORY_PCT is free. If free memory falls to this level then it is unlikely that the JVM will allocate any more. Continuing to extend memory structures such as HashMaps etc is dangerous as there is a real chance of running out of memory.

      See Also:
  • Method Details

    • freeMemAsPct

      public static long freeMemAsPct()
      Return free memory expressed as a percentage of total memory.