0

I have a memory issue when saving images on the background then transferring to gridview full of pictures.

So how my application works:

Activity one "Shows a bunch of images" (Painless loading is enabled in here) Activity two "Save images in the sd card"

The problem I have lies with activity two as it goes to activity one. When items gets saved in the background which shows a lack of images.

What I have tried:

I have tried to call System.gc() before transferring to activity one.

I have tried to create a method and change the variables to null.(Force a garbage collection)

My attempts were unsuccessful. So if someone could give me a better idea on what would be my options for optimizing I would be grateful.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Juju
  • 70
  • 8

1 Answers1

0

I found the reason for the problem yesterday. The problem was me adding the items inside the AsyncTask class and even after completing the class to transfer the next activity. The async class somehow saves its item since I am using a ProgressDialog containing a context within my async class and according to this comment.

"It will hold onto a reference to the Activity, keeping the Activity from being garbage-collected...unless it is a static inner class or fully independent class that has no reference to the Activity or anything that points to the Activity"

commented by CommonsWare.

Community
  • 1
  • 1
Juju
  • 70
  • 8