java - Free up not used View when creating new ones -
I have got two types of array adapter in my application which dynamically loads both data (more or less). The first is connected to a thread that sets fire to every second to refresh the data. The second refreshes the data with an onclick action.
Now when I run my application, I can see with the dampas Memonfu that the view counter is constantly growing (on the piece with thread). Obviously this causes a huge memory leak after a few seconds / minutes. The same happens for onClick.
My impression is that those "old" data are still stored in those views and will not be free. Is there a way to remove every old scene? My adapter is located here;
The main way to use the adapter is (createList ());
Edit: I have found a solution if anyone is interested; As mentioned, need to notify me to use a dataset () - The method whenever I change the data. Working with the list if it is possible only in my example its list & lt; AdapterInit & gt;
which advises me to use the clear ()
along with the methods mentioned. Adapters set on each second are also very bad ideas. Now I will only change the data and the result is expected. A patch below ~ 15,000 to 100-200 can be found on my gitub.
It seems (with the code given below) you are refreshing, telling the adapter that the data has changed Instead, create a new adapter instead of data. Try passing the data to the adapter and then notifyDataSetChanged ();
This will keep you from every other dozen new ideas spamming.
Secondly, you might want to see the garbage collector doing some cleaning at some point. Since you were creating more than one scene several times, you were probably thinking faster than GC, be reasonably unchanged. Your program may have been stopped, if it reached the critical point (not sure). See whether it really will crash because of the memory leak because it is actually a memory leak.
Personal Refreshthread mRefreshThread = new RefreshThread (); Personal handler mRefreshHandler = new handler () {@Override Public Zero handleMessage (Message msg) {if (msg.what> = 1) {if (isVisible () & amp; amp; mVisible) {createList (); MVisible = true; } Else {// nothing}}}}; Public void createList () {// Default View menu adapters Init overview_data [] = new adapterInit [] {// first value (0) is to be images to load new adapterInit (GetString (R.string.kernel_version), AeroActivity. shell.getKernel ()), new adapterInit (GetString (R.string.current_governor), AeroActivity.shell.getInfo (GOV_FILE)), new adapterInit (GetString (Free. string. current_io_governor), Aroaktiv. shell.getInfo (GOV_IO_FILE)) , GetString (R.string.current_cpu_speed), getFreqPerCore (), new GetString (R.string.current_gpu_speed), AeroActivity.shell.getInfo (gpu_file) .substring (0, AeroActivity.shell.getInfo (gpu_file) .length () - 3))), new adapterInit (GetString (R.string.available_memory), AeroActivity.shell.getMemory (FILENAME_PROC_MEMINFO))}; ListView1 = (ListView) root.findViewById (R.id.listView1); Adapters = newActivity (getActivity), R. Late overviewist list, overview_data); ListView1.setAdapter (adapter); }
Comments
Post a Comment