If possible, recover wasted memory.
544125
public void trim() {
    keys = Arrays.copyOf(keys, size);
    values = Arrays.copyOf(values, size);
    for (MappeableContainer c : values) {
      c.trim();
    }
  }
704832
def cleanupmem(initial_memory):
    
    i = 0
    while i < len(initial_memory):
        tmp = initial_memory[i]
        match = RE_LABEL.match(tmp)
        if not match:
            i += 1
            continue

        if tmp.rstrip() == match.group():
            i += 1
            continue

        initial_memory[i] = tmp[match.end():]
        initial_memory.insert(i, match.group())
        i += 1
1336728
function restore() {
    if (isOriginal) return;
    else isOriginal = true;
    ['log', 'debug', 'info', 'warn', 'error'].forEach((item) => {
        console[item] = originalConsoleFunctions[item];
    });
}
862014
def free_memory(cls, exclude=None):
        """"""

        annotations_in_memory = Annotation.__ANNOTATIONS_IN_MEMORY__

        exclude = () if exclude is None else exclude

        for annotation_cls in list(annotations_in_memory.keys()):

            if issubclass(annotation_cls, exclude):
                continue

            if issubclass(annotation_cls, cls):
                del annotations_in_memory[annotation_cls]
256867
def redo(self, channel, image):
        """"""
        self._image = None  # Skip cache checking in set_header()
        info = channel.extdata._header_info

        self.set_header(info, image)
416259
function restoreState(top_err) {
		if (previous_state === true) {
			that.pause(function madePaused(err) {
				// Ignore errors?
				callback(top_err);
			});
		} else {
			callback(top_err);
		}
	}
1335769
public final void reset()
  {

    m_lastChunk = 0;
    m_firstFree = 0;

    // Recover the original chunk size
    FastStringBuffer innermost = this;

    while (innermost.m_innerFSB != null)
    {
      innermost = innermost.m_innerFSB;
    }

    m_chunkBits = innermost.m_chunkBits;
    m_chunkSize = innermost.m_chunkSize;
    m_chunkMask = innermost.m_chunkMask;

    // Discard the hierarchy
    m_innerFSB = null;
    m_array = new char[16][0];
    m_array[0] = new char[m_chunkSize];
  }
246435
synchronized void cleanUpOverMemoryTask(TaskAttemptID tid, boolean wasFailure,
      String diagnosticMsg) {
    TaskInProgress tip = runningTasks.get(tid);
    if (tip != null) {
      tip.reportDiagnosticInfo(diagnosticMsg);
      try {
        purgeTask(tip, wasFailure); // Marking it as failed/killed.
      } catch (IOException ioe) {
        LOG.warn("Couldn't purge the task of " + tid + ". Error : " + ioe);
      }
    }
  }
1070728
def Restore(cls, state):
        """"""

        target = SlotIdentifier.FromString(state.get('target'))
        data = base64.b64decode(state.get('data'))
        var_id = state.get('var_id')
        valid = state.get('valid')

        return ConfigEntry(target, var_id, data, valid)
523566
def _restore(self, value):
        """"""

        items, subs = value
        self.clear()
        for key, value in items:
            self[key] = value
            if key in subs:
                value.sub_frames._restore(subs[key])
350465
def memory_used(self):
        
        if self._end_memory:
            memory_used = self._end_memory - self._start_memory
            return memory_used
        else:
            return None
287711
def _aftermathmp(self):
        """"""
        if not self._flag_e and self._flag_m:
            # join processes
            [proc.join() for proc in self._mpprc]
            if self._exeng == 'server':
                self._mpsvc.join()

            # restore attributes
            if self._exeng == 'server':
                self._frame = list(self._mpfrm)
                self._reasm = list(self._mprsm)
                self._trace = copy.deepcopy(self._mpkit.trace)
            if self._exeng == 'pipeline':
                self._frame = [self._mpkit.frames[x] for x in sorted(self._mpkit.frames)]
                self._reasm = copy.deepcopy(self._mpkit.reassembly)
                self._trace = copy.deepcopy(self._mpkit.trace)

            # shutdown & cleanup
            self._mpmng.shutdown()
            [delattr(self, attr) for attr in filter(lambda s: s.startswith('_mp'), dir(self))]
            self._frnum -= 2
66739
def trace_memory_usage(self, frame, event, arg):
        """"""
        if (event in ('call', 'line', 'return')
                and frame.f_code in self.code_map):
            if event != 'call':
                # "call" event just saves the lineno but not the memory
                mem = _get_memory(-1, include_children=self.include_children)
                # if there is already a measurement for that line get the max
                old_mem = self.code_map[frame.f_code].get(self.prevline, 0)
                self.code_map[frame.f_code][self.prevline] = max(mem, old_mem)
            self.prevline = frame.f_lineno

        if self._original_trace_function is not None:
            (self._original_trace_function)(frame, event, arg)

        return self.trace_memory_usage
939086
def reset(self):
        """"""
        if self.seq is not None and self.shuffle:
            random.shuffle(self.seq)
        if self.last_batch_handle != 'roll_over' or \
            self._cache_data is None:
            if self.imgrec is not None:
                self.imgrec.reset()
            self.cur = 0
            if self._allow_read is False:
                self._allow_read = True
685344
def recover(self, data, redis=None):
        '''  '''
        value = data.get(self.name)

        if value is None or value == 'None':
            return None

        return str(value)
173103
def reset(cls):
        """"""
        cls._codecs = {}
        c = cls._codec
        for (name, encode, decode) in cls._common_codec_data:
            cls._codecs[name] = c(encode, decode)
289727
private function restoreLastUserInput()
    {
        $this->userInput = $this->lastInput;
        $this->cursorPosition = mb_strlen($this->userInput);
    }