Just for the sake of clarity, I take it that Heap must look like this: Inductive Heap A : Type := | Node : Heap A -> A -> Heap A -> Heap A | Leaf : Heap A. with f being defined as Fixpoint f A (h : Heap...

There are two main approaches for finding stack buffer overflows: Black box testing The key to testing an application for stack overflow vulnerabilities is supplying overly large input data as compared to what is expected. However, subjecting the application to arbitrarily large data is not sufficient. It becomes necessary to...

The easiest method to increase the heap space is using the -Xmx<SizeInGigs>g option to the JVM command. For example: java -Xmx4g -jar $pathofjarfile parameter1 parameter2 Since you have a path to home/bin/myapp jar you will either need to modify the script/application launching the JVM to follow suite or ask about...

as title says, Where is Heap and Stack on Physical Memory? Ever since CPUs have had MMUs to add a layer of indirection between virtual memory and physical memory, heap and stack have been anywhere in physical memory. Ever since modern Operating Systems have implemented ASLR, heap and stack...

In your example data, [5, 53, 531, 5131], the computation as you have expressed it in sift_up will go like this: # Append 1 to the end --> [5, 53, 531, 5131, 1] # The index for '1' is 4, so 'item' is 4. # (4-1) // 2 = 1...

It's likely that OutOfMemoryError occurs not in Eclipse, but in the spawned JVM where your application works. You should modify parameters in your run configuration. Go to Run -> Run Configurations, find your application run configuration in the left pane and select it. On the right pane select "Arguments" tab,...

No, you are confused on your data structures. Heaps do not guarantee an ordering in the way a BST(binary search tree) does. Heaps only guarantee that a given node's children satisfy the heap property (ie. either they are all less than the given subtree root for a max heap, or...

I'm assuming you're asking in regards to this. You don't necessarily need to create more than Integer.MAX_VALUE objects. You just need to create some until there is a collision. You can do that relatively easily. public static void main(String[] args) throws Exception { final int LENGTH = Integer.MAX_VALUE / 256;...

Your two examples are not equivalent: In the Java example, you forgot to actually create an object. Corrected code: class Thingy; Thingy foo() { Thingy a = new Thingy(); return a; } Syntax for Java pointers and C++ pointers are different, because Java does not allow stack-allocation, only heap-allocation, and...

It turns out that adding up the EU and OU columns of jstat is approximately equal to the heap usage shown in jvisualvm. The EU+OU is always about 12 MB less than what's shown in jvisualvm for the process that I am monitoring. (In the example I provided in my...

(Yes - FreeRTOS pvPortMalloc() returns void*.) If you have 60K of SRAM, and configTOTAL_HEAP_SIZE is large, then it is unlikely you are going to run out of heap after allocating 256 bytes unless you had hardly any heap remaining before hand. Many FreeRTOS demos will just keep creating objects until...

Never mark your copy constructor or move constructor as explicit. It isn't illegal. It is just unusual enough to be confusing. There is no benefit to it, and only downside. The explicit on your move constructor is the cause of this error....

First of all, you are aware that C++ has std::stack built in, aren't you? For the rest of the answer, I'll assume that you have some reason not to use it (perhaps it's a learning exercise). A very naïve way to achieve what you want would be: On every addition...

what is pSharp It's a pointer to a Sharp object instance. what is &pSharp It's the address of operator (it doesn't matter that this is a pointer). what is &pSharp[0] I don't know why it's written this way but it's just taking the address and the [0] just starts...

The problem is that the array is being passed to the Box::new function as an argument, which means it has to be created first, which means it has to be created on the stack. You're asking the compiler to create 8 megabytes of data on the stack: that's what's overflowing...

There is already multiple memory regions, but only one Java heap as such. Typically there are; Java heap which might be broken into Eden space, Survivor Spaces, Tenures space. The native memory heap for small direct memory allocation. e.g. ByteBuffer.allocateDirect(4) See missing [heap] section in /proc/pid/maps for an interesting discussion...

Your problem seems to be in your enqueue. def enqueue(self, item, priority): self.PQ.insert(item) The priority parameter is not used at all. Instead, your heap is using string comparisons. This is the state of your heap before any dequeue: [None, 'Yamagata', 'Tetsuo', 'Shikishima', 'Takashi', 'Masaru', 'Akira', 'Kiyoko', 'Kei', 'Kaneda'] ...

The sequence is correct except one point: The delete []ip; removes the memory allocated on the heap to the ip pointer. The pointer that got passed through to myFun now points to nothing. The pointer doesn't point to 'nothing' (i.e. isn't set to nullptr or 0 after freeing the memory)....

From the very bottom of this page from the Swift Reference: NOTE The description above refers to the “copying” of strings, arrays, and dictionaries. The behavior you see in your code will always be as if a copy took place. However, Swift only performs an actual copy behind the scenes...

You need to do a memory trace by using the memory profiler in VisualVM. A simple way to do a memory profile is to run jmap -histo:live {pid} | head If you are using SQL, the most likely cause of a memory leak is failing to clean up your JDBC...

A recursive method (it doesn't really matter if it's recursive or not) can access static members of the class to which it belongs, as well as non static members (assuming the recursive method is not static). This data is in the heap. However, if you wish to mutate the array...

The Fortran standard does not speak about stack and heap at all, that is an implementation detail. In which part of memory something is placed and whether there are any limits is implementation defined. Therefore it is impossible to control the stack or heap behaviour from the Fortran code itself....

The method System.out.print(Object o) uses the parameter Object's toString() method. If you have not overridden this method to provide custom behavior, it will use the parent method (in this case, the default Object.toString()). To print the value of MaxHeap, override it's toString method, returning a String that you want to...

After more testing and reading I saw in MSDN that kernel32.dll also exports Heap functions. Kernel32 has a function HeapSize that returns what we need. It seems that the Kernel functions just channel through the ntdll counterparts. Therefore I suspected that ntdll should have a counterpart to HeapSize. I looked...

Since T cached is declared inside the method I assume it is allocated on the stack, right? T being allocated in a method doesn't effect it being on the heap or the stack. The decision whether it is the former or the latter is based on whether this is...

If you must use recursion, then put those recyclable variables inside a struct, and pass that reusable struct instance (instantiated at the outermost layer of recursion) by reference to your recursive calls.

First, for the base data structure, typically Guava's Multiset<String> is preferable to Map<String, Integer> in the same way that Set<String> is preferable to Map<String, Boolean>. It's a cleaner API and encapsulates the incrementing. Now, if this were me, I would implement a custom Multiset which adds some additional logic to...

The second form of std::push_heap takes custom comparator as the third parameter, so you can give it the < overload: struct SPtrNodeLess { bool operator()(const std::shared_ptr<Node> &first, const std::shared_ptr<Node> &second) const { return *first < *second; } } std::push_heap(h.begin(), h.end(), SPtrNodeLess()) The std::find_if takes the unary predicate in similar fashion:...

Out of range exceptions are generally easy to track down. Basically, you have to make sure that whenever you're accessing an item in an array via indexes, said array's count / length is greater than the index. In other words, ensure that in every call to heap[#index], #index < heap.Count...

No ... the thread shares memory with the main thread and all other threads started by the app. That is what makes multi-threading more difficult. You have to be careful when multiple threads access the same memory. Threads all share the same resources but only the main thread can interact...

One Oracle java command line flag named -XshowSettings may help you understand what is going on. On my machine (Ubuntu 12.04) with Oracle JVM 1.7.0_75, this program runs fine, producing no output as desired, for a 100MB file: $ java -XshowSettings:vm -cp target/classes/:/data/home/kmhaswade/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar foo.TestClass VM settings: Max. Heap Size (Estimated):...

Firstly it seems strange, but as usual there is no magic. The only way to find out the answer is to go deeper: to the openjdk sources. Just checkout and try to grep: grep -r "Xmx" . There will be many tests, but they are not interesting to us. Two...

Yes, references get updated during a garbage collection. Necessarily so, objects are moved when the heap is compacted. Compacting serves two major purposes: it makes programs more efficient by using the processor's data caches more efficiently. That is a very, very big deal on modern processors, RAM is exceedingly slow...

Thanks to the suggestion on using PerfView by magicandre1981, and after quite a few very large memory dumps, I've located this issue down to the use of DataRow.DefaultIfEmpty() in a Linq expression. It was part of a support function for carrying out a LeftJoin between two DataTables. With the DefaultIfEmpty()...

When you write past the end of an array you get undefined behaviour. The important word is undefined. It may depend on the compiler, the environment, the compiler flags, ... In you example it worked because you wrote on a memory that is accessible, but you could (non limitative list)...

When arrays are declared in Java, they are stored as an array of references. You wouldn't run into this overhead cost when initializing an array of the Line class in C++ because your array will hold the objects, not merely their references.

The first line of code is correct, you initialize a statically allocated CClass instance with an another instance dynamically allocated. The second is obviously wrong as you try to delete an object that has not been dynamically allocated . The first line produces a memory leak because you dynamically allocate...

You may use the combination of jmap/jhat tools (Both these are unsupported as of Java 8) to gather the heap dump (using mmap) and identify the top objects in heap (using jhat). Try to co-relate these objects with the application and identify the rogue one.

What usually happens from my experience is that aVeryLargeString exceeds the capacity of *ps, so *ps allocates extra memory, keeping the starting position the same. No, this is not generally true. When you exceed the capacity, the string uses its allocator to allocate a completely different block (with size...

For the specific case of Cortex-M processors, word-alignment is sufficient for heap allocations as there are no instructions on the Cortex-M that have a stricter alignment requirement than word-alignment. For the Cortex-M4 this is declared in the Cortex-M4 Devices Generic User Guide Section 3.3.5: An aligned access is an operation...

I'm not an expert in C, not even a middle, most of the time I program in C#, so some mistakes might be there. Modern operating systems have a special mechanism called the memory manager. Using that mechanism we can ask OS to give us some amount of memory. In...

Actually it's what swap does, swaps program data and stack space: http://www.linuxjournal.com/article/10678 These are placed in anonymous pages, so named because they have no named filesystem source. Once modified, an anonymous page must remain in RAM for the duration of the program unless there is secondary storage to write it...

The sync block has more than one use. It can store the value of Object.GetHashCode() so that an object always returns the same hash code when GetHashCode() is called again. It can store the ID of the owner thread of a lock statement. It has several dedicated bits, like indicating...

You have memory leak and undefine behaviour! : scoreList.append(*newScore); this line is going to copy the *newScore and then append it to scoreList. so you will leak newScore. and this line : foreach (Types::SSensorScore score, scoreList) delete &score; It will delete the the copy of object so it's undefine behaviour....

Not sure about GS collections and your cases, but you also might be interested in these libraries: https://github.com/JCTools/JCTools for very efficient concurrent queues http://fastutil.di.unimi.it for priority queues ...

A warning is printed as i compiled your code by gcc main.c -o main -Wall : main.c:51:9: attention : format ‘%lf’ expects argument of type ‘double *’, but argument 2 has type ‘int *’ [-Wformat] I was able to reproduce the heap corruption by using a size of 6. The...

This is impossible if priorities can be compared only. The problem is that a constant-time merge can be used to simulate insert in constant time, which, since delete-min also is constant-time, violates the known lower bound on sorting.

In a d-ary heap, up-heaps (e.g., insert, decrease-key if you track heap nodes as they move around) take time O(log_d n) and down-heaps (e.g., delete-min) take time O(d log_d n), where n is the number of nodes. The reason that down-heaps are more expensive is that we have to find...

Each time you're inserting an element, check the minimum of the min heap and the maximum of the max heap to see which heap each element belongs in. When you see 20, both heaps are empty, so it doesn't matter -- let's say in case of a tie we'll put...

Building a heap (also called Heapify) is always O(n), regardless of the input distribution or the branching factor of the heap (binary, ternary heaps...). You misread the provided link, it states: (emphasis is mine) Although the worst case complexity looks like O(nLogn), upper bound of time complexity is O(n)....

A heap may have better insert and merge times. It really depends on the type of heap, but typically they are far less strict than an AVL because they don't have to worry about auto balancing after each operation. A heap merely guarantees that all nodes follow the same style...

This has nothing to do with heap vs stack, and everything to do with assignment semantics of primitives vs reference types. Object assignment in Java does not copy, so Test test1=test; just creates another "name" (another variable) which refers to the same object in memory. Primitive assignment does copy, so...

why the leaf "4" under path 9-6-5-4 is the left side child of node "5", not the right side one? Because if it was on the right side, that would mean there is a gap in the underlying vector. The tree structure is for illustrative purposes only. It is...

The porblem with array is not to find the place where you need to insert the element, it is to actually insert it. It will require you to shift all elements next to it by one index, and this will cost O(n). Example: [1,5,8,10,15], you need to insert 4,...

The so-called "median of medians" algorithm can find the kth smallest element in an unordered set in O(n) time. You want to apply this for k = n/5 and k = 4n/5. The result of the algorithm is a partially-ordered array where the desired kth element is in location k....

Nodes with equal keys are OK. Recall the heap property: for min-heap, the key of each node is greater than or equal to the key of its parent. (The max-heap property can similarly defined.) A Fibonacci heap is just a collection of such trees. If more than one root has...

I got answer for my problem after reading a lot for continuous 3 days finally my problem is solved. Well, what's happening is that setBackgroundResource(R.drawable.imageName) is going to cause Android to first do the BitmapFactory.decodeResource() Which will actually do some resampling based on screen density (i.e., automatic density-based resampling for...

mapreduce.reduce.shuffle.input.buffer.percent 0.70 The percentage of memory to be allocated from the maximum heap size to storing map outputs during the shuffle. From this it looks that that if you decrease this to a arbitrary value it may degrade the performance of the shuffle phase. There would have been certain reasoning...

I think I solved the problem. You have to "patch" your JRE with some files of the JDK (same version of course - if you are running jre6uXX you need the corresponding files from jdk6uXX ) Copy the following files: \JDK6uXX\bin\attach.dll --> %JAVAJRE_HOME%\bin\ \JDK6uXX\bin\jmap.exe --> %JAVAJRE_HOME%\bin\ \JDK6uXX\lib\tools.jar --> %JAVAJRE_HOME%\lib\ No...

The two iterators passed as first and second arguments to the function std::make_heap has to be RandomAccessIterators. List iterators are not RandomAccessIterators while std::vector and std::array's are. In the standard this is specified in the interface for make_heap at §25.1: template<class RandomAccessIterator> void make_heap(RandomAccessIterator first, RandomAccessIterator last); template<class RandomAccessIterator, class Compare>...

The memory limits you specify in mapred-site.xml need to be below yarn-site.xml memory settings then calculated w/system resources. I use a script for this for collecting the system specifics and create my core-site, mapred-site, hdfs-site and yarn-site.xml configuration. Note: Mapreduce runs on top of yarn so remember to always have...

I would guess that remove() decreases heap size by 1. So, for each iteration of your loop, you are incrementing i by 1 and decrementing heap size by 1. I would change to a while loop that runs while heapsize >0.

Qt will just call your destructor, it doesn't go and delete every member of your class itself! If you have a delete[] myArray in your class's destructor, your array will be deleted correctly. If you don't delete[] your array in the destructor, it will leak. But better yet, don't bother...

new unsigned char(sizeof(BITMAPFILEHEADER)); This does not allocate an array! It allocates a single unsigned char. Write: new unsigned char[sizeof(BITMAPFILEHEADER)]; You get that right later on in your code, so presumably this is just a typo....

Since this is presumably homework, all I can do is give hints, which is often easier done as comments. Since this ended up being a fairly thorough series of hints I'm summarizing them as an answer here. For the most part, methods in your PriorityQueue class will map to methods...

Stack behaves as LIFO with PUSH and POP insturctions.But that doesnt mean without pop you can read the stack memory . In your case you push int first (* its not a opcode of machine, just trying to explain) push double second push float third Now you have 2 options...

I think you're reading too much into a connection between the comparator semantics and the heap semantics. Remember, the internal details and structure of containers are deliberately abstracted away from you so, the moment you started trying to rationalise about this in terms of how you think the internal structure...

libconfig is passing you a pointer to its internal string storage for the timeformat value. Which then gets freed when you do a config_destroy() causing your global struct's timeformat pointer to be invalid. To avoid this strdup() the timeformat string returned to you by libconfig: const char *time_str; config_lookup_string(&cfg, "timeformat",...

Below pointerToPointer = new char[3]; char y[3] = {'x', 'y', 'z'}; pointerToPointer = y; you allocate memory to pointerToPointer (first line), then make pointerToPointer point to the beginning of the array y (third line). When you try to delete pointerToPointer, you effectively try to delete a pointer that points to...

Well, I assume you're talking about a binary heap data structure. That means that each step in the tree is going to have 2^n nodes in it. The total number of nodes in the tree is going to be 2^(n-1) + 1. A heap of height 6 is going to...

When you start a program, some amount of memory is allocated for the program; however, this amount of memory is not the limit to what the program is allowed to use. Whenever more memory is requested, it can be granted up until the system has used up all of the...

You can find detailed documentation on memory leak detection by AppDynamics from the following links (depending on whether you use Java or .NET): https://docs.appdynamics.com/display/PRO40/Automatic+Leak+Detection+for+Java https://docs.appdynamics.com/display/PRO40/Monitor+Memory+Usage+with+Object+Instance+Tracking+for+.NET...

Depends on what 'big' means. This link shows the default stack size limits for some OSes. You'll want to make sure that the size MainComponent allocates on the stack is well below any of these numbers. Further, if there are certain things being dynamically created, or certain arrays/assets that are...

You are not allocating enough memory in your newarray to allot for the end of string terminating character: newArray=(char *)realloc(NULL,length*sizeof(char)); Later you are setting: newArray[j]='\0'; where j exceeds the memory size by 1. Change to: newArray=(char *)realloc(NULL,length*sizeof(char) + 1); and newArray[j-1]='\0' Also need to reset j....

Your fixheap2 fails to consider the case where both children are valid but have keys smaller than the parent's. In that situation, the heap property has been restored, and you should stop swapping with children (or you'll re-invalidate it).

Both classes and closures are reference types. var foo = Foo() creates a Foo object on the heap, and stores a (strong) reference to that object in the local stack variable foo. return { foo } creates a closure which captures foo, so that the closure holds another (strong) reference...

String is immutablabe means you cannot change the string value on the same address if you change it will create a new object and you have to assign it to the current string object Fo ex String a = "Hariom"; a.replace('H', 'b'); System.out.println(a); //will print Hariom because a is not...