Such a limit is a good idea.  We might want such
governors in the abstract memory cache and in the
abstract disk cache.  They should be configurable. 
The indexed disk cache uses memory for keys.  You can
set a maximum number of keys, but this isn't
absolutely safe.

The maxMemory method is jdk 1.4 specific, so whatever
we do will have to be in the 1.4 src directory.  Ugh.

I'm not sure how to put something like this in given
our src split.


Aaron

--- Hanson Char <[EMAIL PROTECTED]> wrote:
> If too much stuff is put into a Java caching system
> too fast, one may run
> into the JVM out-of-memory problem.
> 
> One idea is that every time there is a "put"
> operation (which is the only
> operation that may increase the memory usage by the
> caching system), the
> caching system checks if the current JVM memory
> usage is over a particular
> threshold, and if so temporarily disable the "put"
> by making it a no-op.
> 
> Something like:
> 
>         static final float
> MEMORY_USAGE_THRESHOLD_PERCENT = 70.0F;
>         ...
>         // Method of putting stuff to the cache
>         public Serializable put(Serializable stuff)
> {
>                 Runtime rt = Runtime.getRuntime()
>                 double mFree = rt.freeMemory();
>                 double mMax = rt.maxMemory();
>                 double mTotal = rt.totalMemory();
>                 double usage = (mMax - mTotal +
> mFree) / mMax * 100
> 
>                 if (usage >
> MEMORY_USAGE_THRESHOLD_PERCENT)
>                         return null;    // cache
> "put" temporarily disabled
>                 // normal put
> 
>                 ...
>         }
> 
> 
> With such measures, if there was a out-of-memory
> problem, it still wouldn't
> be caused directly by the caching system.
> 
> Good idea ?
> 
> Regards,
> Hanson
> 



                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to