heap

When and why to declare member variables on the heap C++

谁都会走 提交于 2019-12-18 12:18:42
问题 Ok, so I'm very new at C++ programming, and I've been looking around for a couple days for a decisive answer for this. WHEN should I declare member variables on the heap vs. the stack? Most of the answers that I've found have dealt with other issues, but I want to know when it is best to use the heap for member variables and why it is better to heap the members instead of stacking them. 回答1: There are two important concepts to grasp first: One should avoid thinking in terms of "heap" and

When and why to declare member variables on the heap C++

陌路散爱 提交于 2019-12-18 12:18:32
问题 Ok, so I'm very new at C++ programming, and I've been looking around for a couple days for a decisive answer for this. WHEN should I declare member variables on the heap vs. the stack? Most of the answers that I've found have dealt with other issues, but I want to know when it is best to use the heap for member variables and why it is better to heap the members instead of stacking them. 回答1: There are two important concepts to grasp first: One should avoid thinking in terms of "heap" and

JMeter OutOfMemoryError

久未见 提交于 2019-12-18 12:14:54
问题 I am facing below OutOfMemor errors, and JMeter stops working.... java.lang.OutOfMemoryError: Java heap space Dumping heap to java_pid4412.hprof ... Heap dump file created [591747609 bytes in 71.244 secs] Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space Exception in thread "AWT-EventQueue-0" java

When should I use make_heap vs. Priority Queue?

纵饮孤独 提交于 2019-12-18 12:07:33
问题 I have a vector that I want to use to create a heap. I'm not sure if I should use the C++ make_heap function or put my vector in a priority queue? Which is better in terms of performance? When should I use one vs. the other? 回答1: There's no difference in therms of performance. std::priority_queue is just an adapter class that wraps the container and the very same heap-related function calls into a class. The specification of the std::priority_queue openly states that. By building a heap-based

What is Python's heapq module?

痴心易碎 提交于 2019-12-18 10:04:15
问题 I tried "heapq" and arrived at the conclusion that my expectations differ from what I see on the screen. I need somebody to explain how it works and where it can be useful. From the book Python Module of the Week under paragraph 2.2 Sorting it is written If you need to maintain a sorted list as you add and remove values, check out heapq. By using the functions in heapq to add or remove items from a list, you can maintain the sort order of the list with low overhead. Here is what I do and get.

what happens in the kernel during malloc?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 09:54:24
问题 I was asked this question during an interview. What they wanted to know was when the user calls malloc(4) to allocate 4 bytes of memory how does the operating system (Linux) respond? Which subsystem responds to this system call? I told him that malloc() will be serviced by the memory management subsystem. The malloc() implementation will go through the list of free memory(physical memory), we will call it free list, and find an appropriate chunk that is greater than or equal to 4 Bytes. Once

Increase heap to avoid Out of Memory Error in WEKA

你。 提交于 2019-12-18 08:46:31
问题 I am trying to run a classifier in WEKA, using a J48 classifier using the following command line: $ java -Xmx2048m -cp /home/weka-3-7-9/weka.jar weka.classifiers.trees.J48 -t input.arff -i -k -d J48-data.model & Although the size of my arff is 43.8 M, and I aumented the heap space to 2048m, I still received the following errors: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.ArrayList.<init>(ArrayList.java:132) at weka.core.Instances.initialize(Instances

SBT runs out of memory

喜你入骨 提交于 2019-12-18 07:45:15
问题 I am using SBT 0.12.3 to test some code and often I get this error message while testing interactively with the ~test command. 8. Waiting for source changes... (press enter to interrupt) [info] Compiling 1 Scala source to C:\Users\t\scala-projects\scala test\target\s cala-2.10\classes... sbt appears to be exiting abnormally. The log file for this session is at C:\Users\t\AppData\Local\Temp\sbt566325905 3150896045.log java.lang.OutOfMemoryError: PermGen space at java.util.concurrent.FutureTask

What is the time complexity of constructing a PriorityQueue from a collection?

情到浓时终转凉″ 提交于 2019-12-18 06:01:26
问题 What is the complexity of Java's PriorityQueue constructor with a Collection ? I used the constructor: PriorityQueue(Collection<? extends E> c) Is the complexity O(n) or O(n*log(n))? 回答1: The time complexity to initialize a PriorityQueue from a collection, even an unsorted one, is O(n). Internally this uses a procedure called siftDown() to "heapify" an array in-place. (This is also called pushdown in the literature.) This is counterintuitive. It seems like inserting an element into a heap is

What's the meaning of “Internal” in “!heap -h” output in windbg?

∥☆過路亽.° 提交于 2019-12-18 04:52:54
问题 I am following this stackoverflow post What do the different columns in the "!heap -flt -s xxxx" windbg command represent I am trying to understand the information printed out for one of the heaps that using up a lot of memory. I can understand most of the columns but on my windbg, I see an additional column. Most of my entries are marked as Internal . I wonder what that means. I have done !gflags +ust . So, I can see the call stack for making the memory allocation. I can do it on most of the