memory-leaks

JDBC communication link failure after some time

落花浮王杯 提交于 2019-12-23 01:35:16
问题 I am using JDBC with proxool connection pool to connect to mysql DB. I am selecting large number of rows from multiple threads and after some time i get an error saying communication link failure, Last packet sent to the server was ...ago. I am closing connection,statement,resultSet in every thread. The fetching time increases gradually and the exception occurs after 5-10 minutes. I doubt it is a memory leak, but cant find any clue. Please let me know the possible reasons. Thanks, Kaka 回答1:

Garbage Collector too slow when working with large images

独自空忆成欢 提交于 2019-12-22 22:20:55
问题 I am using Emgu OpenCV to grab images from a webcam and want to visualize them with WPF Image Control. So I need to convert the image from Mat to something compatible with Image control. So I took this class from the Emgu examples: public static class BitmapSourceConvert { /// <summary> /// Delete a GDI object /// </summary> /// <param name="o">The poniter to the GDI object to be deleted</param> /// <returns></returns> [DllImport("gdi32")] private static extern int DeleteObject(IntPtr o); ///

Strange behaviour while Unit testing for memory leak using WeakReference

假装没事ソ 提交于 2019-12-22 19:18:14
问题 I'm trying to write a unit test for testing a memory leak. Steps to Reproduce: TestClass test = new TestClass(); WeakReference reference = new WeakReference(test, true); test = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Debug.Assert(reference.Target == null, "Memory Leak"); // This works //Replacing the above line with following, I see "Memory Leak" being printed. if (reference.Target != null) { Console.WriteLine("Memory Leak"); } I added a finalizer: ~TestClass() {

How can I prevent Eclipselink from consuming all memory with the cache?

和自甴很熟 提交于 2019-12-22 18:33:49
问题 My application extracts large amounts of geometry data. I use Eclipselink 2.4.1 to persist that data in a MySQL database. The application works batch-style, i.e. I gather a set of data, then persist it, and continue with the next set, persist it and so on. Another application later reads that data and processes it, but this question is only about the first application that gathers the data. The data-gathering application runs for quite some time. I use a fixed set of EntityManagers which are

Android - Alternative to async tasks?

﹥>﹥吖頭↗ 提交于 2019-12-22 18:11:28
问题 So I have an app in which I use an async task to fetch in data from a Django backend using rest API. This will be used the first time when the device needs to be synced with the site. So this sync task fetches in quite a lot of data (2 GB). And I have read in many places that async tasks really should be used when the process takes not more than 2-3 seconds. Definitely gonna take longer in my case. So what is my alternative here? Handlers? Can someone point to a tutorial or article explaining

iOS - NSNotificationCenter memory leak

不羁岁月 提交于 2019-12-22 18:02:31
问题 Instruments reports this a memory leak (98.6%, whatever that means): [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationSomeNotification object:self]; "self" is a subclass of UIImageView. Is including "self" in the notification causing a memory leak? If so, how do you resolve it? 回答1: Better check your notification observer. The cause of memory leak might be there. 回答2: Memory leaks are almost always it is not safe. Check again are there leakage accurately!? You can do

Using SoftReference for static data to prevent memory shortage in Java

北城余情 提交于 2019-12-22 16:44:09
问题 I have a class with a static member like this: class C { static Map m=new HashMap(); { ... initialize the map with some values ... } } AFAIK, this would consume memory practically to the end of the program. I was wondering, if I could solve it with soft references, like this: class C { static volatile SoftReference<Map> m=null; static Map getM() { Map ret; if(m == null || (ret = m.get()) == null) { ret=new HashMap(); ... initialize the map ... m=new SoftReference(ret); } return ret; } } The

Good way to clear nested Maps in Java

匆匆过客 提交于 2019-12-22 14:59:15
问题 public class MyCache { AbstractMap<String, AbstractMap<String, Element>> cache = new TreeMap<String, AbstractMap<String, Element>>(); public Boolean putElement(String targetNamespace, Element element) { ... } public void clear() { cache.clear(); } // is it better this way? public void deepClear() { for(AbstractMap<String, Element> innerMap : cache.values()) { innerMap.clear(); } cache.clear(); } } Is it necessary to iterate over the values of the root map and clear all the maps nested in the

Memory blowing up for strict sum/strict foldl in ghci

梦想与她 提交于 2019-12-22 12:37:41
问题 As mentioned in Why does (sum $ takeWhile (<10000000) [1..]) use so much memory? the following does not blow up the memory in ghci : foldl' (+) 0 $ takeWhile (< 10000000) [1 .. ] However if I create a file containing : import Data.List longList::[Int] longList = [1 .. ] result :: Int result = foldl' (+) 0 $ takeWhile (< 10000000) longList main = do print $ result and load into ghci, then upon running the program the memory consumption blows up. Why is this, and what can I do to fix the

Memory Leak in Titanium tabbed iPhone application

对着背影说爱祢 提交于 2019-12-22 12:22:18
问题 this has been giving me a headache for a couple weeks now -- hope somebody can help. I'm building an app for iOs 5.0, using the 2.1.4 SDK in Titanium mobile. My app pulls data from a database, and displays it in a scrollableview using labels and a table. I've noticed that it crashes after a while, and according to instruments, the views within the scrollableView, along with the labels and tableviews, are never released from memory. I use a lot of commonJS, and my code looks someting like this