pm.removeReferences(channelID, toRemove);
pm.removeDepagedReferences(channelID, toRemove);
   protected void loadPagedReferences(long number) throws Exception   {      if (trace) { log.trace(this + " Loading " + number + " paged references from storage"); }      // Must flush the down cache first      flushDownCache();            List refInfos = pm.getPagedReferenceInfos(channelID, firstPagingOrder, number);            Map refMap = processReferences(refInfos);      boolean loadedReliable = false;      List toRemove = new ArrayList();            int unreliableNumber = 0;      Iterator iter = refInfos.iterator();      while (iter.hasNext())      {         ReferenceInfo info = (ReferenceInfo)iter.next();                  MessageReference ref = addFromRefInfo(info, refMap);                  if (recoverable && ref.isReliable())         {            loadedReliable = true;         }         else         {            // We put the non reliable refs (or reliable in a non-recoverable store)            // in a list to be removed            toRemove.add(ref);                        unreliableNumber++;         }      }      if (!toRemove.isEmpty())      {         // Now we remove the references we loaded (only the non persistent or persistent in a non-recoverable store)                  pm.removeReferences(channelID, toRemove);      }      if (loadedReliable)      {         // If we loaded any reliable refs then we must set the page ordering to null in         // the store otherwise they may get loaded again, the next time we do a load         // We can't delete them since they're reliable and haven't been acked yet                     pm.updateReliableReferencesNotPagedInRange(channelID, firstPagingOrder, firstPagingOrder + number - 1, number - unreliableNumber);      }                  firstPagingOrder += number;            if (firstPagingOrder == nextPagingOrder)      {         //No more refs in storage         firstPagingOrder = nextPagingOrder = 0;                  if (messageRefs.size() != fullSize)         {            paging = false;         }      }       }