heap

How to find which objects are creating the most garbage

橙三吉。 提交于 2019-12-22 10:44:19
问题 I have an application with about 80 instances of 80 different classes. The amount of garbage generated by some subset of these classes is unacceptable and stop the world pauses are too long, since my application is real time. What I want to find is which classes are responsible for creating the largest number of objects on heap (not aggregate size, but raw number of objects), since this is what causes stop the world pauses to take so long. How do I find this out? If JVisualVM is required, I

Why is the top down approach of heap construction less efficient than bottom up even though its order of growth is lower O(log n) over O(n)?

扶醉桌前 提交于 2019-12-22 10:41:40
问题 How is the bottom up approach of heap construction of the order O(n) ? Anany Levitin says in his book that this is more efficient compared to top down approach which is of order O(log n). Why? 回答1: That to me seems like a typo. There are two standard algorithms for building a heap. The first is to start with an empty heap and to repeatedly insert elements into it one at a time. Each individual insertion takes time O(log n), so we can upper-bound the cost of this style of heap-building at O(n

Process Heap Segments And Their Necessity

自闭症网瘾萝莉.ら 提交于 2019-12-22 10:27:58
问题 While dumping heap of a win32 processes (Mostly in process which has high heap memory consumption like IE ) using !heap -a 004e0000 I find multiple segments of a particular heap like , Heap entries for Segment00 in Heap 004e0000 Heap entries for Segment01 in Heap 004e0000 Heap entries for Segment02 in Heap 004e0000 My questions are Question 1. Why its necessory to divide single heap into multiple segments ? Question 2. Most of the times I find a large gap between two segments. For example in

C# Garbage collection

拥有回忆 提交于 2019-12-22 08:06:09
问题 say we have: public void foo() { someRefType test = new someRefType (); test = new someRefType (); } What does the garbage collector do with the first heap object? Is it immediately garbage collected before the new assignment? What is the general mechanism? Thanks, Juergen 回答1: What does the garbage collector do with the first heap object? Who knows? It's not deterministic. Think of it like this: on a system with infinite memory, the garbage collector doesn't have to do anything . And you

Where does exception object have its space, heap or stack, and how to access it in different class?

半腔热情 提交于 2019-12-22 07:49:21
问题 Recently an interviewer asked me where the exception object in C++ is allocated, heap or stack? I'm not sure but I answered stack since I thought there is no "new" or "malloc". Is it correct? Then he kept asking me that if it's on stack, assuming class A throw a exception object, let's say "e", and class B catch "e". Since "e" is on the stack of A, then how does B can have the access to this "e"? I'm not very clear about the second question. Could anyone can give me some example code showing

2D Matrix allocation on heap in c++

梦想的初衷 提交于 2019-12-22 06:59:11
问题 I am looking for a way to allocate a 2D (m x n) matrix on the heap where the elements are consecutive in memory. Currently I know of two ways to accomplish that: First approach int* M = new int[m * n]; Pro: The size of M can by dynamically determined. Con: Indexing of M is a bit of a pain. ( M[i * m + j] ) Second approach typedef int dim[2]; dim* M = new dim[n]; Pro: Indexing of M is just how I want it to be. Con: The size of the first dimension (m) cannot be set dynamically. Question Is

Quick successful exit from C++ with lots of objects allocated

有些话、适合烂在心里 提交于 2019-12-22 06:56:08
问题 I'm looking for a way to quickly exit a C++ that has allocated a lot of structures in memory using C++ classes. The program finishes correctly, but after the final "return" in the program, all of the auto-destructors kick in. The problem is the program has allocated about 15GB of memory through lots of C++ class structures, and this auto-destruct process takes about 1 more hour itself to complete as it walks through all of the structures - even though I don't care about the results. The

Advantages of a Binary Heap for a Priority Queue?

爱⌒轻易说出口 提交于 2019-12-22 06:36:24
问题 It seems I'm missing something very simple: what are advantages of a Binary Heap for a Priority Queue comparing, say, with quick-sorted array of values? In both cases we keep values in an array, insert is O(logN), delete-max is O(1) in both cases. Initial construction out of a given array of elements is O(NlogN) in both cases, though the link http://en.wikipedia.org/wiki/Heap_%28data_structure%29 suggests faster Floyd's algorithm for the Binary Heap construction. But in case of a queue the

What is dirty private memory?

橙三吉。 提交于 2019-12-22 05:23:08
问题 I'm developing an application on a 64-bit Linux system. As I could see, my app is eating too much dirty heap memory. Talking about the heap memory, what does "dirty" mean? What makes it arise and what can be done to prevent it to arise? EDIT I'd better explain what operations my application performs. My application runs in two threads: the first thread sends jobs to a queue which are then executed in another thread. So, the first thread allocates pages to be queued and the second thread

Print a tree in sorted order using heap properties (Cormen)

只谈情不闲聊 提交于 2019-12-22 04:58:16
问题 I am refreshing on algorithm theory (from Cormen). There is an exercise in the chapter for binary tries that asks: Can the min-heap property be used to print out the keys of an n-node tree in sorted order in O(n) time? Show how, or explain why not. I thought yes it is possible. In the min heap the element in a node is smaller than both its children. So the root of the heap is always the smaller element of all the n elements and the left child of the root is the smaller than all the elements