heap

Android Bitmap Memory Issue - Error: Out of memory on a 8294416-byte allocation

非 Y 不嫁゛ 提交于 2019-12-20 09:59:40
问题 I am currently developing an app that goes through a story. The story contains "scenes" which contain multiple JPEG and PNG files that are displayed via ImageViews. I create the ImageView and add at it to the layout via the following function: private ImageView newImage(Show show) { ImageView iv = new ImageView(this); String filePath = comin.generateFilePath(show); Log.i(TAG, "newImage, filePath = " + filePath + " id = " + show.id); WeakReference<Bitmap> bmp = new WeakReference<Bitmap>

easy way to maintain a min heap with stl?

我是研究僧i 提交于 2019-12-20 09:36:35
问题 for user defined struct, as I understand, it's easy. Just overload the operator <. However, for int/float etc.., do I really need to overload operator < for int? Here is what I tried: #include <iostream> #include <algorithm> #include <vector> using namespace std; bool comp(const int& a, const int& b) { return a<b?false:true; } int main () { int myints[] = {10,20,30,5,15}; vector<int> v(myints,myints+5); vector<int>::iterator it; make_heap(v.begin(), v.end(), comp); cout << "initial min heap :

What's the node.js memory breakdown?

房东的猫 提交于 2019-12-20 09:16:29
问题 We are deploying a Node.js application. This app seems to be consuming way more RSS memory than it should. So we started to dive into things and we found the following, thanks to process.memoryUsage(); The RSS memory grows quickly to about 400MB and stays more or less stable in a 400MB-500MB, with small ups and small downs (Garbage collector running?) The heapUsed quickly grows to 50MB and then stays at that level (between 20MB and 100MB). The heaptotal is always about 30MB more MB than the

C# - Garbage Collection

亡梦爱人 提交于 2019-12-20 08:50:12
问题 Ok so I understand about the stack and the heap (values live on the Stack, references on the Heap). When I declare a new instance of a Class, this lives on the heap, with a reference to this point in memory on the stack. I also know that C# does it's own Garbage Collection (ie. It determines when an instanciated class is no longer in use and reclaims the memory). I have 2 questions: Is my understanding of Garbage Collection correct? Can I do my own? If so is there any real benefit to doing

How do Haskell compilers decide whether to allocate on the heap or the stack?

谁都会走 提交于 2019-12-20 08:49:33
问题 Haskell doesn't feature explicit memory management, and all objects are passed by value, so there's no obvious reference counting or garbage collection either. How does a Haskell compiler typically decide whether to generate code that allocates on the stack versus code that allocates on the heap for a given variable? Will it consistently heap or stack allocate the same variables across different call sites for the same function? And when it allocates, how does it decide when to free memory?

Difference between priority queue and a heap

↘锁芯ラ 提交于 2019-12-20 08:49:06
问题 It seems that a priority queue is just a heap with normal queue operations like insert, delete, top, etc. Is this the correct way to interpret a priority queue? I know you can build priority queues in different ways but if I were to build a priority queue from a heap is it necessary to create a priority queue class and give instructions for building a heap and the queue operations or is it not really necessary to build the class? What I mean is if I have a function to build a heap and

How to use mmap to allocate a memory in heap?

て烟熏妆下的殇ゞ 提交于 2019-12-20 08:46:16
问题 Just the question stated, how can I use mmap() to allocate a memory in heap? This is my only option because malloc() is not a reentrant function. 回答1: Why do you need reentrancy? The only time it's needed is for calling a function from a signal handler; otherwise, thread-safety is just as good. Both malloc and mmap are thread-safe. Neither is async-signal-safe per POSIX. In practice, mmap probably works fine from a signal handler, but the whole idea of allocating memory from a signal handler

Use a heap overflow to write arbitrary data

安稳与你 提交于 2019-12-20 08:42:51
问题 I've been trying to learn the basics of a heap overflow attack. I'm mostly interested in using a corruption or modification of the chunk metadata for the basis of the attack, but I'm also open to other suggestions. I know that my goal of the exploit should be do overwrite the printf() function pointer with that of the challenge() function pointer, but I can't seem to figure out how to achieve that write. I have the following piece of code which I want to exploit, which is using malloc from

Trying to get my matrix printed not the heap address

≡放荡痞女 提交于 2019-12-20 07:39:42
问题 The code seems to run except what I am getting is not a matrix of a specified (by the user) size but what I think is a heap address Here's what it returns when the user inputs 2 for the size and then 4 numbers: Enter matrix size: 2 Enter a 2 by 2 matrix row by row: 2 3 4 5 The row-sort matrix is...[[D@3c954549BUILD SUCCESSFUL (total time: 8 seconds) here is the code....thank you in advance. import java.util.Scanner; public class Exercise7_26M { public static void main (String[]args) { /

Java heap profiling crashes with SIGABRT

岁酱吖の 提交于 2019-12-20 06:40:30
问题 I'm trying to profile native memory allocated by C-written methods and plugged to JVM through JNI . I installed $ valgrind --version valgrind-3.13.0 And tried to run JVM with the following options: valgrind --tool=massif --massif-out-file=/tmp/massif-j.out java -XX:+UnlockDiagnosticVMOptions //... The thing is it crashes with core dump created 0x00000000080e4196: fxrstor64 (%rsp) 0x00000000080e419b: add $0x200,%rsp 0x00000000080e41a2: mov (%rsp),%r15 0x00000000080e41a6: mov 0x8(%rsp),%r14