Release resources used by supporting classes
485955
def cleanup(self):
        
        try:
            self.unload_lime()
        except AttributeError as ex:
            pass
        self.tunnel.cleanup()
        self.shell.cleanup()
1317002
protected void releaseResources()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "releaseResources : State = " + stateStrs[state]);

        // If the state is not complete, then the ContainerTx should not
        // be cleared, and should not be returned to the pool.  This is common
        // for BMT, where a method may begin the tx, but not complete it
        // until a subsequent method call.                                 d157262
        if (state != COMMITTED && state != ROLLEDBACK)
        {
            return;
        }

        // Simply clear all instance variables that may hold a reference to
        // another object.                                                 d215317

        afterList = null;
        beanOList = null;
        beanOs = null;
        cmdAccessor = null;
        containerAS = null;
        currentBeanOs = null;
        finderSyncList = null;
        homesForPMManagedBeans = null;
        ivContainer = null;
        ivPostProcessingException = null; // PQ90221
        ivTxKey = null;
        tempList = null;
        txListener = null;
        uowCtrl = null;
        timersQueuedToStart = null; // F743-425.CodRev
        timersCanceled = null; // F743-425.CodRev
    }
537791
public static final void destroy() {
		if (CClassLoader.rootLoader == null) {
			return;
		}
		System.out.println("Destroying YAHP ClassLoader Tree");

		CClassLoader.urlLoader = null;

		try {
			Field f = Class.forName("java.lang.Shutdown").getDeclaredField(
					"hooks");
			f.setAccessible(true);
			ArrayList l = (ArrayList) f.get(null);
			for (Iterator it = l.iterator(); it.hasNext();) {
				Object o = it.next();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			Field f = Class.forName("java.lang.ApplicationShutdownHooks")
					.getDeclaredField("hooks");
			f.setAccessible(true);
			IdentityHashMap l = (IdentityHashMap) f.get(null);
			for (Iterator it = l.entrySet().iterator(); it.hasNext();) {
				Entry e = (Entry) it.next();
				Thread o = (Thread) e.getKey();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
					continue;
				}
				o = (Thread) e.getValue();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			if ((UIManager.getLookAndFeel() != null)
					&& (UIManager.getLookAndFeel().getClass().getClassLoader() != null)
					&& (UIManager.getLookAndFeel().getClass().getClassLoader()
							.getClass() == CClassLoader.class)) {
				UIManager.setLookAndFeel((LookAndFeel) null);
			}
			Field f = UIManager.class.getDeclaredField("currentLAFState");
			f.setAccessible(true);
			Object lafstate = f.get(null);
			if (lafstate != null) {
				Field fmultiUIDefaults = lafstate.getClass().getDeclaredField(
						"multiUIDefaults");
				fmultiUIDefaults.setAccessible(true);
				Object multiUIDefaults = fmultiUIDefaults.get(lafstate);
				Method clear = multiUIDefaults.getClass().getDeclaredMethod(
						"clear", (Class[]) null);
				clear.setAccessible(true);
				clear.invoke(multiUIDefaults, (Object[]) null);
				Field tbl = lafstate.getClass().getDeclaredField("tables");
				tbl.setAccessible(true);
				Hashtable[] tables = (Hashtable[]) tbl.get(lafstate);
				if (tables != null) {
					for (int i = 0; i < tables.length; i++) {
						Hashtable element = tables[i];
						if (element != null) {
							element.clear();
						}
					}
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			Hashtable tb = UIManager.getDefaults();
			Object cl = tb.get("ClassLoader");
			if (cl.getClass() == CClassLoader.class) {
				tb.put("ClassLoader", CClassLoader.rootLoader.getParent());
			}
		} catch (Throwable ignore) {
		}

		Method logFactoryRelease = null;

		try {
			logFactoryRelease = CClassLoader.rootLoader.loadClass(
					"org.apache.commons.logging.LogFactory").getMethod(
					"release", new Class[] { ClassLoader.class });
		} catch (final Throwable ignore) {
		}

		CClassLoader.rootLoader._destroy(logFactoryRelease);
		CClassLoader.mandatoryLoadersMap.clear();
		CClassLoader.rootLoader = null;

		// deregister any sql driver loaded
		try {
			final List deregisterList = new ArrayList();
			for (final Enumeration it = DriverManager.getDrivers(); it
					.hasMoreElements();) {
				final Driver d = (Driver) it.nextElement();

				if ((d != null)
						&& (d.getClass().getClassLoader() != null)
						&& (d.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					deregisterList.add(d);
				}
			}

			for (int i = 0; i < deregisterList.size(); i++) {
				final Driver driver = (Driver) deregisterList.get(i);
				DriverManager.deregisterDriver(driver);
			}
		} catch (final Throwable ignore) {
		}

		// stop dandling thread created with this classloader
		// tested only on sun jdk
		ThreadGroup tg = Thread.currentThread().getThreadGroup();
		while ((tg != null) && (tg.getParent() != null)) {
			tg = tg.getParent();
		}
		List ltg = new ArrayList();
		ltg.add(tg);
		CClassLoader.getThreadGroups(tg, ltg);
		for (int ii = 0; ii < ltg.size(); ii++) {
			try {
				final ThreadGroup g = (ThreadGroup) ltg.get(ii);
				final Field fthreads = ThreadGroup.class
						.getDeclaredField("threads");
				fthreads.setAccessible(true);

				final List toStop = new ArrayList();
				Object threads[] = null;

				if (fthreads.getType() == Vector.class) {
					// in gnu classpath
					threads = ((Vector) fthreads.get(g)).toArray();
				} else {
					// sun
					threads = (Object[]) fthreads.get(g);
				}

				for (int i = 0; i < threads.length; i++) {
					if (threads[i] == null) {
						continue;
					}
					if ((threads[i] != null)
							&& (((Thread) threads[i]).getContextClassLoader() != null)
							&& (((Thread) threads[i]).getContextClassLoader()
									.getClass() == CClassLoader.class)) {
						((Thread) threads[i]).setContextClassLoader(null);
					}
					if ((threads[i] != null)
							&& (threads[i].getClass().getClassLoader() != null)
							&& (threads[i].getClass().getClassLoader()
									.getClass() == CClassLoader.class)) {
						toStop.add((Thread) threads[i]);
					}

					// remove any object in threadLocal referring an object
					// loaded
					// by this classloader tree
					try {
						final Field fthreadLocals = Thread.class
								.getDeclaredField("threadLocals");
						fthreadLocals.setAccessible(true);

						final Object threadLocals = fthreadLocals
								.get(threads[i]);
						if (threadLocals != null) {
							final Field ftable = threadLocals.getClass()
									.getDeclaredField("table");
							ftable.setAccessible(true);

							final Object table[] = (Object[]) ftable
									.get(threadLocals);

							for (int kk = 0; kk < table.length; kk++) {
								final Object element = table[kk];
								if (element != null) {
									final Field fvalue = element.getClass()
											.getDeclaredField("value");
									fvalue.setAccessible(true);

									final Object value = fvalue.get(element);

									if ((value != null)
											&& (value.getClass()
													.getClassLoader() != null)
											&& (value.getClass()
													.getClassLoader()
													.getClass() == CClassLoader.class)) {
										fvalue.set(element, null);
									}
									if (value instanceof Map) {
										clearMap((Map)value);
									} else if (value instanceof List) {
										clearList((List)value);
									} else if (value instanceof Set) {
										clearSet((Set)value);
									} else if (value instanceof Object[]) {
										clearArray((Object[])value);
									}

									fvalue.setAccessible(false);
								}
							}
							ftable.setAccessible(false);
						}
						fthreadLocals.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}

					// remove any object in threadLocal referring an object
					// loaded
					// by this classloader tree
					try {
						final Field fthreadLocals = Thread.class
								.getDeclaredField("inheritableThreadLocals");
						fthreadLocals.setAccessible(true);

						final Object threadLocals = fthreadLocals
								.get(threads[i]);
						if (threadLocals != null) {
							final Field ftable = threadLocals.getClass()
									.getDeclaredField("table");
							ftable.setAccessible(true);

							final Object table[] = (Object[]) ftable
									.get(threadLocals);

							for (int kk = 0; kk < table.length; kk++) {
								final Object element = table[kk];
								if (element != null) {
									final Field fvalue = element.getClass()
											.getDeclaredField("value");
									fvalue.setAccessible(true);

									final Object value = fvalue.get(element);

									if ((value != null)
											&& (value.getClass()
													.getClassLoader() != null)
											&& (value.getClass()
													.getClassLoader()
													.getClass() == CClassLoader.class)) {
										fvalue.set(element, null);
									}
									if (value instanceof Map) {
										clearMap((Map)value);
									} else if (value instanceof List) {
										clearList((List)value);
									} else if (value instanceof Set) {
										clearSet((Set)value);
									} else if (value instanceof Object[]) {
										clearArray((Object[])value);
									}

									fvalue.setAccessible(false);
								}
							}

							ftable.setAccessible(false);
						}
						fthreadLocals.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}

					// remove any protection domain referring this loader tree
					try {
						final Field finheritedAccessControlContext = Thread.class
								.getDeclaredField("inheritedAccessControlContext");
						finheritedAccessControlContext.setAccessible(true);

						final Object inheritedAccessControlContext = finheritedAccessControlContext
								.get(threads[i]);

						if (inheritedAccessControlContext != null) {
							final Field fcontext = AccessControlContext.class
									.getDeclaredField("context");
							fcontext.setAccessible(true);

							final Object context[] = (Object[]) fcontext
									.get(inheritedAccessControlContext);

							if (context != null) {
								for (int k = 0; k < context.length; k++) {
									if (context[k] == null) continue;
									final Field fclassloader = ProtectionDomain.class
											.getDeclaredField("classloader");
									fclassloader.setAccessible(true);

									final Object classloader = fclassloader
											.get(context[k]);

									if ((classloader != null)
											&& (classloader.getClass() == CClassLoader.class)) {
										context[k] = null;
									}

									fclassloader.setAccessible(false);
								}
							}

							fcontext.setAccessible(false);
						}

						finheritedAccessControlContext.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}
				}

				fthreads.setAccessible(false);
				for (int i = 0; i < toStop.size(); i++) {
					try {
						final Thread t = (Thread) toStop.get(i);
						final Method stop = t.getClass().getMethod("stop",
								(Class[]) null);
						stop.invoke(t, (Object[]) null);
					} catch (final Throwable ignore) {
					}
				}
			} catch (final Throwable ignore) {
			}
		}
		try{CThreadContext.destroy();}catch(Throwable ignore){}
		System.runFinalization();
		System.gc();
		Introspector.flushCaches();
		System.out.println("Destroying YAHP ClassLoader Tree : done");
	}
222758
def _closeResources(self):
        
        self.viewBox.sigRangeChangedManually.disconnect(self.setAutoRangeOff)
        self.viewBox.sigRangeChanged.disconnect(self.refreshMinMax)
872351
protected void releaseTable() {
		// set the counters back
		this.numBuckets = 0;
		
		if (this.buckets != null) {
			for (MemorySegment bucket : this.buckets) {
				this.availableMemory.add(bucket);
			}
			this.buckets = null;
		}
	}
1269153
void releaseResources(JobInstance ji)
    {
        this.peremption.remove(ji.getId());
        this.actualNbThread.decrementAndGet();

        for (ResourceManagerBase rm : this.resourceManagers)
        {
            rm.releaseResource(ji);
        }

        if (!this.strictPollingPeriod)
        {
            // Force a new loop at once. This makes queues more fluid.
            loop.release(1);
        }
        this.engine.signalEndOfRun();
    }
861321
public void dispose() {
        if (_cacheFile != null && _dirty) {
            PrintStream out = null;
            try {
                File parent = _cacheFile.getParentFile();
                if (parent.isDirectory() || parent.mkdirs()) {
                    out = new PrintStream(_cacheFile);
                    for (List<Resource> bundleInfoList : _cacheBySymbolicName.values()) {
                        for (Resource bundleInfo : bundleInfoList) {
                            out.println(bundleInfo);
                        }
                    }
                }
            } catch (IOException e) {
            } finally {
                Utils.tryToClose(out);
            }
        }
        _bundleLocations.clear();
        _cacheBySymbolicName.clear();
    }
216867
def release_api_class(self):
        """"""
        cls = current_app.config['GITHUB_RELEASE_CLASS']
        if isinstance(cls, string_types):
            cls = import_string(cls)
        assert issubclass(cls, GitHubRelease)
        return cls
148110
function (classpath, dependencies) {
            if (this.__cssDependencies[classpath]) {
                dependencies = this.__cssDependencies[classpath];
            }

            this.unloadClassPathDependencies(classpath, dependencies);
        }
787334
@SuppressWarnings("unused")
    private static void releaseRenderer() 
    {
        if (log.isLoggable(Level.FINEST))
        {
            log.finest("releaseRenderer rendererMap -> " + delegateRendererMap.toString());
        }
        
        
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        
        if (log.isLoggable(Level.FINEST))
        {
            log.finest("releaseRenderer classLoader -> " + classLoader.toString() );
            log.finest("releaseRenderer renderer -> " + delegateRendererMap.get(classLoader));
        }
        
        
        delegateRendererMap.remove(classLoader);
        
        if (log.isLoggable(Level.FINEST))
        {
            log.finest("releaseRenderer renderMap -> " + delegateRendererMap.toString());
        }
        
    }
469357
private synchronized void unloadSources() {
        nodesSourceList = new ArrayList<>();
        Closeables.closeQuietly(nodeSourceReferences);
        nodeSourceReferences = new HashSet<>();
        sourcesOpened = false;
    }
1010625
public void releaseAllResources()
    {
        super.releaseAllResources();
        synchronized (poolSynch)
        {
            if (!poolMap.isEmpty())
            {
                Collection pools = poolMap.values();
                Iterator iterator = pools.iterator();
                ObjectPool op = null;
                while (iterator.hasNext())
                {
                    try
                    {
                        op = (ObjectPool) iterator.next();
                        op.close();
                    }
                    catch (Exception e)
                    {
                        log.error("Exception occured while closing ObjectPool " + op, e);
                    }
                }
                poolMap.clear();
            }
            dsMap.clear();
        }
    }
533151
public void release() 
    { 
        if (!_hasAcquired)
            return;

        // Deliver the onRelease event to the registered listeners
        for (ResourceEvents resourceListener : _listeners)
            resourceListener.onRelease();

        // Unregister this ResourceContext with associated container context
        _containerContext.removeResourceContext(this, _bean);

        // Reset the flag to indicate resources have been released.
        _hasAcquired = false;
    }
487395
protected void releaseTable() {
		// set the counters back
		this.numBuckets = 0;
		
		if (this.buckets != null) {
			for (int i = 0; i < this.buckets.length; i++) {
				this.availableMemory.add(this.buckets[i]);
			}
			this.buckets = null;
		}
	}
1198590
private void exportResources(PluginClassLoaderDef def, ClassloaderBuilder builder, Collection<PluginClassLoaderDef> allPlugins) {
    // export the resources to all other plugins
    builder.setExportMask(def.getBasePluginKey(), def.getExportMask());
    for (PluginClassLoaderDef other : allPlugins) {
      if (!other.getBasePluginKey().equals(def.getBasePluginKey())) {
        builder.addSibling(def.getBasePluginKey(), other.getBasePluginKey(), new Mask());
      }
    }
  }
779233
public void forceClose() {
        // Move all elements from usedInstances to unusedInstances in a threadsafe way
        for (final T usedInstance : new ArrayList<>(usedInstances)) {
            if (usedInstances.remove(usedInstance)) {
                unusedInstances.add(usedInstance);
            }
        }
        close();
    }
1050867
public void free()
    {
        super.free();
        try
        {
            if (this.getHandle(DBConstants.DATA_SOURCE_HANDLE) != null)
                ((BaseBuffer)this.getHandle(DBConstants.DATA_SOURCE_HANDLE)).free();
        } catch (DBException ex)    {
            // Never
        }
        if (m_pTable != null)
            m_pTable.removePTableOwner(this, true);      // Free or decrement the use count of the physical table
        m_pTable = null;
    }