public void add(PipImage img, int frame, int trans, Image swtImg) {
   Key newKey = new Key(img, frame, trans);
   if (searchTable.containsKey(newKey)) {
     GLUtils.unloadImage(searchTable.get(newKey));
     searchTable.put(newKey, swtImg);
   } else {
     if (keyList.size() >= capacity) {
       Key key = keyList.remove(0);
       Image obsoleteImage = searchTable.remove(key);
       GLUtils.unloadImage(obsoleteImage);
       obsoleteImage.dispose();
     }
     keyList.add(newKey);
     searchTable.put(newKey, swtImg);
   }
 }
 public void clear() {
   for (Image img : searchTable.values()) {
     GLUtils.unloadImage(img);
   }
   keyList.clear();
   searchTable.clear();
 }
 public void remove(PipImage img) {
   for (int i = 0; i < keyList.size(); i++) {
     Key key = keyList.get(i);
     if (key.img == img) {
       keyList.remove(i);
       i--;
       Image bufferImg = searchTable.remove(key);
       GLUtils.unloadImage(bufferImg);
       bufferImg.dispose();
     }
   }
 }
 protected void finalize() throws Throwable {
   for (Image img : searchTable.values()) {
     GLUtils.unloadImage(img);
   }
 }