title: How to keep memory empty? Android
body: <p>My app has two 'heavy' fragments. When i move between them everytime allocate memory ~ 40mb. Meanwhile they haven't large bitmaps or something like that. And every time garbage collector free a little part of allocated memory ~10mb . My question what have i do to prevent allocate memory or free it? </p>
  
  <pre><code>@Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      onCreateCreator();
      name_text = (TextView) getView().findViewById(R.id.info_title);
      artist_text = (TextView) getView().findViewById(R.id.info_artist);
      info_duration = (TextView) getView().findViewById(R.id.info_duration);
      crossfade_duration = (TextView) getView().findViewById(R.id.crossfade_duration_text);
      crossfade_duration.setOnClickListener(this);
      increase_duration = (TextView) getView().findViewById(R.id.increase_duration_text);
      increase_duration.setOnClickListener(this);
      fading_duration = (TextView) getView().findViewById(R.id.fading_duration_text);
  
      crossfade_switch = (Switch) getView().findViewById(R.id.crossfade_switch);
      crossfade_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
              if (!b) {
                  fading_switch.setChecked(false);
              }
              fading_switch.setEnabled(b);
          }
      });
  
      fading_switch = (Switch) getView().findViewById(R.id.fading_switch);
      increase_switch = (Switch) getView().findViewById(R.id.increase_switch);
  
      save = (Button) getView().findViewById(R.id.save);
      save.setOnClickListener(this);
      save_to_playlist = (Button) getView().findViewById(R.id.save_to_playlist);
      save_to_playlist.setOnClickListener(this);
  
      cover = (ImageView) getView().findViewById(R.id.info_cover);
  
      skip = (RelativeLayout) getView().findViewById(R.id.skip_layout);
      skip.setOnClickListener(this);
      if (MODE == MODE_SINGLE) {
          skip.setVisibility(View.GONE);
          fill(track);
      }
      else {
          skip.setVisibility(View.VISIBLE);
          fill(tracks.get(0));
      }
  }
  
  private void fill(Track track){
  
      this.track = track;
      cover.setImageBitmap(default_cover);
      int end_millis = Integer.valueOf(Settings.getMetadata(track.getPath(), MediaMetadataRetriever.METADATA_KEY_DURATION));
      name_text.setText(track.getName());
      artist_text.setText(track.getArtist());
      info_duration.setText(getResources().getString(R.string.info_duration) + ": " + Settings.getUserInterfaceDuration(end_millis, true, false));
      if (task != null) task.cancel(true);
      task = new MyTask(cover);
      task.execute(track);
  
      crossfade_duration.setText(String.valueOf(Settings.CROSSFADE_START));
      fading_duration.setText(String.valueOf(Settings.CROSSFADE_START));
      increase_duration.setText("0");
      fading_switch.setEnabled(false);
  
      fading_switch.setChecked(track.isFading());
  
      if (track.isMegamixTrack()){
          if (track.getCrossfadeDuration() &gt; 1000){
              crossfade_switch.setChecked(true);
              crossfade_duration.setText(String.valueOf(track.getCrossfadeDuration()));
              fading_duration.setText(String.valueOf(track.getCrossfadeDuration()));
          }
          if (track.getIncrease() &gt; 0){
              increase_switch.setChecked(true);
              increase_duration.setText(String.valueOf(track.getIncrease()));
          }
      } else{
          crossfade_switch.setChecked(false);
          increase_switch.setChecked(false);
      }
  }
  </code></pre>