我一直在研究一個應用程序一段時間,使用大量的位圖,我得到了它的工作真正在大多數設備上,我已經測試過的點除外對於運行更新的機器人仿生2.3.4android-java-轉換WeakReference <Bitmap>爲一個正常的位圖
我得到一個內存不足的錯誤,我也可以看到在logcat中增長的堆。到目前爲止,我已經嘗試用不同的技術重新調整位圖,這對除了新的機器人仿生學以外的其他設備都很好,這很奇怪,因爲你會認爲新手機會更好地處理vm。
我在這裏看了一些其他線程,談論使用各種方法,但有興趣使用的一個Im涉及使用WeakReferenced來存儲圖像。這很好,但我怎樣才能將弱引用轉換回正常位圖以在畫布上使用。
編輯:繼承人最近的堆棧跟蹤dumparoo:對
09-30 12:33:09.231 2867 2922 E AndroidRuntime: FATAL EXCEPTION: go
09-30 12:33:09.231 2867 2922 E AndroidRuntime: java.lang.OutOfMemoryError
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.io.AbstractSessionInputBuffer.init(AbstractSessionInputBuffer.java:79)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:93)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:83)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:170)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:106)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:129)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:363)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at graffit.data.ImageGrabber.imagegetter(ImageGrabber.java:164)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at graffit.data.ImageGrabber.traverseIDS(ImageGrabber.java:118)
09-30 12:33:09.231 2867 2922 E AndroidRuntime: at graffit.data.ImageGrabber$getMarkImageThread.run(ImageGrabber.java:238)
09-30 12:33:09.239 480 750 W ActivityManager: Force finishing activity graffit.main/.GraffView
09-30 12:33:09.669 480 873 I ActivityManager: Process graffit.main (pid 2867) has died.
09-30 12:33:09.677 480 590 I WindowManager: WINDOW DIED Window{407c4100 graffit.main/graffit.main.GraffView paused=true}
09-30 12:33:09.677 480 590 I WindowManager: WINDOW DIED Window{408044e0 Toast paused=false}
09-30 12:33:09.684 480 759 I WindowManager: Setting rotation to 0, animFlags=1
是啊,這是我有花花公子的確切問題。繼承人堆棧跟蹤的東西添加到我的問題上面。 –
HttpPost post = new HttpPost(strUrl); \t \t \t \t後。setEntity(new UrlEncodedFormEntity(nvp1)); \t \t \t \t try {System.gc(); \t \t \t \t \t \t \t \t響應= client.execute(後);所以這個響應= client.execute(post);是logcat指出的罪魁禍首。我將如何使用httpconnectionsparams。 –
AH哈哈.....我有男人.....我寫了這樣,它像魔術post = new HttpPost(strUrl); \t \t \t \t params = post.getParams(); \t \t \t \t post.setEntity(new UrlEncodedFormEntity(nvp1)); \t \t \t \t try {System.gc(); \t \t \t \t HttpConnectionParams.setSocketBufferSize(params,8192); \t \t \t \t response = client.execute(post); –