* NativeObjectManager is now limited for 100 objects deleted per frame to reduce spikes with large heap config

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9319 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..rd 13 years ago
parent 0751d9ff76
commit 9390125d6c
  1. 18
      engine/src/core/com/jme3/util/NativeObjectManager.java

@ -51,6 +51,12 @@ public class NativeObjectManager {
private static final Logger logger = Logger.getLogger(NativeObjectManager.class.getName()); private static final Logger logger = Logger.getLogger(NativeObjectManager.class.getName());
/**
* The maximum number of objects that should be removed per frame.
* If the limit is reached, no more objects will be removed for that frame.
*/
private static final int MAX_REMOVES_PER_FRAME = 100;
/** /**
* The queue will receive notifications of {@link NativeObject}s which are no longer * The queue will receive notifications of {@link NativeObject}s which are no longer
* referenced. * referenced.
@ -91,15 +97,19 @@ public class NativeObjectManager {
* Deletes unused GLObjects * Deletes unused GLObjects
*/ */
public void deleteUnused(Object rendererObject){ public void deleteUnused(Object rendererObject){
while (true){ int removed = 0;
while (removed < MAX_REMOVES_PER_FRAME) {
NativeObjectRef ref = (NativeObjectRef) refQueue.poll(); NativeObjectRef ref = (NativeObjectRef) refQueue.poll();
if (ref == null) if (ref == null)
return; break;
refList.remove(ref); refList.remove(ref);
ref.objClone.deleteObject(rendererObject); ref.objClone.deleteObject(rendererObject);
if (logger.isLoggable(Level.FINEST)) removed++;
logger.log(Level.FINEST, "Deleted: {0}", ref.objClone); }
if (removed >= 1) {
//System.out.println("NativeObjectManager: " + removed + " native objects were removed from GL");
logger.log(Level.FINE, "NativeObjectManager: {0} native objects were removed from GL", removed);
} }
} }

Loading…
Cancel
Save