memory

Android: Converting ArrayList to GSON runs out of memory

大憨熊 提交于 2020-01-06 08:26:29
问题 Hoping someone out there can explain this to me. I keep running out of memory when trying to store an ArrayList in my SharedPreferences . public void setCurrentAlarmList(ArrayList<CurrentAlarm> currentAlarms) { Log.e("SETTING LIST", "!!!"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); SharedPreferences.Editor editor = prefs.edit(); Gson gson = new Gson(); String json = gson.toJson(currentAlarms); editor.putString(Constants.ALARM_LIST, json); editor.apply(

Reading part of a file in C using fread() and fseek()

大兔子大兔子 提交于 2020-01-06 08:12:46
问题 I'm trying to read a file into a buffer in blocks of size BLOCK_SIZE (currently equal to 1000 unsigned chars ). My code initially finds the number of blocks it will have to read in order to read the entire file (usually 2-4), then iterates through a for loop reading the file (ignore the " +17+filenamesize " stuff, that is all needed for later in the program. However, only on the first time, when j=1 , does it actually put data into the buf array. In other cases, when j != 1 , strlen(buf)

Reading part of a file in C using fread() and fseek()

不羁岁月 提交于 2020-01-06 08:12:25
问题 I'm trying to read a file into a buffer in blocks of size BLOCK_SIZE (currently equal to 1000 unsigned chars ). My code initially finds the number of blocks it will have to read in order to read the entire file (usually 2-4), then iterates through a for loop reading the file (ignore the " +17+filenamesize " stuff, that is all needed for later in the program. However, only on the first time, when j=1 , does it actually put data into the buf array. In other cases, when j != 1 , strlen(buf)

Another memory leak question

跟風遠走 提交于 2020-01-06 06:57:34
问题 My application keeps running for 4 to 6 hours, During this time there is no contineous increase in memory or anything similar. Then after 4 to 6 hours i start getting EOutofMemory Exceptions. Even still at that time there is only 900MB out of 3GB RAM is used as per task manager. And application itself is not using more then 200MB . Then why i am getting EOoutofMEmory error ? Does it mean that memory leak is not necessarily visible in task manager ? Regagards 回答1: Use Process Explorer instead

C++ Screen capture fail after hundreds repetitions on Windows: memory leak?

梦想的初衷 提交于 2020-01-06 06:49:07
问题 I use a function which captures a screen using the BitBlt mehtod and can then return a HBITMAP . int screenCapture() { int width = 1000; int height = 700; HDC hdcTemp, hdc; BYTE* bitPointer; hdc = GetDC(HWND_DESKTOP); hdcTemp = CreateCompatibleDC(hdc); BITMAPINFO bitmap; bitmap.bmiHeader.biSize = sizeof(bitmap.bmiHeader); bitmap.bmiHeader.biWidth = width; bitmap.bmiHeader.biHeight = -height; bitmap.bmiHeader.biPlanes = 1; bitmap.bmiHeader.biBitCount = 24; bitmap.bmiHeader.biCompression = BI

List of lists vs single list memory usage in Python

我与影子孤独终老i 提交于 2020-01-06 06:37:13
问题 I have a bunch of numbers that I have to organize and am thinking of organizing in lists them by their semantic meaning. What is the overhead in terms of memory usage of organizing data as a list of lists versus a single flat list in python? I.e. [[x1,y1,v1],[x2,y2,v2], ... , [xn,yn,vn]] [x1,y1,v1,x2,y2,v2, ... , xn,yn,vn] 回答1: There would be very, very little overhead. Organize your data in whichever way makes the most semantic sense, and don't worry about performance until it's actually a

Why memory limit exceeded and how can i avoid this?

痴心易碎 提交于 2020-01-06 06:28:38
问题 import java.util.*; public class AlmostPerfect { public static void main(String[] args) { Scanner x = new Scanner(System.in); while(x.hasNext()){ int n = x.nextInt(); int sum = recursion(n,n-1,0); if (sum == n) { System.out.println(n + " perfect"); } else if ((n - sum) <= 2) { System.out.println(n + " almost perfect"); } else { System.out.println(n + " not perfect"); } } } public static int recursion(int n, int x,int sum) { if(x==0){ return sum; } else if (n % x == 0) { sum+=x; return

PHP performance: Memory-intensive variable

佐手、 提交于 2020-01-06 05:39:15
问题 Supposing a multidimensional associative array that, when printed as text with print_r() , creates a 470 KiB file. Is it reasonable to assume that the variable in question takes up half a MiB of server memory per instance if it is different for each user? Therefore if 1000 users hit the server at the same time almost half a GiB of memory will be consumed? Thanks. 回答1: There is an excellent article on this topic at IBM: http://www.ibm.com/developerworks/opensource/library/os-php-v521/ UPDATE

Memory exception in C# [duplicate]

丶灬走出姿态 提交于 2020-01-06 04:38:07
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: How to refer to children in a tree with millions of nodes I'm trying to implement a tree which will hold millions of nodes, which in turn can have an unspecified number of children nodes. To achieve this (since each node can have more than one child node), I'm storing a node's children within a Dictionary data structure. As a result of this, when each object node is created (out of millions), I've got a node

advice with pointers in matlab

倖福魔咒の 提交于 2020-01-06 03:43:10
问题 I am running a very large meta-simulation where I go through two hyperparameters (lets say x and y) and for each set of hyperparameters (x_i & y_j) I run a modest sized subsimulation. Thus: for x=1:I for y=1:j subsimulation(x,y) end end For each subsimulation however, about 50% of the data is common to every other subsimulation, or subsimulation(x_1,y_1).commondata=subsimulation(x_2,y_2).commondata. This is very relevant since so far the total simulation results file size is ~10Gb! Obviously,