FAQ Database Discussion Community


Deleting excess variables from stack - C++

c++,recursion,stack,heap,stack-overflow
I have a recursive function that declares at least 50KB of local variables in one call and a stack overflow might be likely with the number of recursive steps I'll need. However, by the time the function is called within itself, these variables aren't needed anymore. Can I delete them,...

How can I change maximum available heap size for a task in FreeRTOS

embedded,malloc,heap,keil,freertos
I'm creating a list of elements inside a task in the following way: l = (dllist*)pvPortMalloc(sizeof(dllist)); dllist is 32 byte big. My embedded system has 60kB SRAM so I expected my 200 element list can be handled easily by the system. I found out that after allocating space for 8...

Heap Corruption while getting LU factorization's nxn matrix

c,heap,factorization
im trying to make LU factorization on n x n(getting n from scanf) matrix HEAP CORRUPTION causes when i try to make n x n matrix and put numbers in :/ i dont know where to fix as i am using malloc for the first time #include <stdio.h> #include <stdlib.h>...

Increase the java heap space of a certain app

java,performance,hadoop,out-of-memory,heap
I have an application that I want to run it and gives it more heap memory. I run my application using this command in terminal: home/bin/hadoop jar $pathofjarfile parameter1 parameter2 but I don't know how to allocate more heap memory when running this application? if anyone could please advise.

Testing My Heap

java,sorting,heap
1.) I'm having difficulty testing me heap class. When I try to print my heap, it's giving me code instead of the array. I tried using toString() and DeeptoString() and neither worked. 2.) In my updateValue method. I realize that it doesn't know what to do once it's reached a...

Python Heap Priority Queue sift_up()

python,queue,heap,priority-queue
I am still rather new to Python, but am having a problem with a heap priority queue. Here are my init(), str(), add(), and my sift_up() method: def __init__(self): self.queue = [] def __str__(self): return str(self.queue) def add(self, item): self.queue.append(item) self.sift_up(len(self.queue) - 1) def sift_up(self, item): parent = (item -...

Apache Hadoop 2.6 Java Heap Space Error

java,apache,hadoop,runtime-error,heap
I'm getting: 15/04/27 09:28:04 INFO mapred.LocalJobRunner: map task executor complete. 15/04/27 09:28:04 WARN mapred.LocalJobRunner: job_local1576000334_0001 java.lang.Exception: java.lang.OutOfMemoryError: Java heap space at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462) at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522) Caused by: java.lang.OutOfMemoryError: Java heap space at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.init(MapTask.java:983) at...

Global struct memory error

c,struct,heap,valgrind
My program's reading from config file using libconfig and saving values to the global struct. It's working fine but valgrind says there's error. And the error only shows for char pointer variable. What is that error and how to fix that ? Thank you #include <stdio.h> #include <libconfig.h> #include "stdlib.h"...

Deallocating member pointer

c++,pointers,memory,dynamic,heap
#include <iostream> using namespace std; class myClass{ public: char * pointer; char * pointerToPointer; myClass(){ pointer = new char; char x = 'x'; pointer = &x; pointerToPointer = new char[3]; char y[3] = {'x', 'y', 'z'}; pointerToPointer = y; } ~myClass(){ delete pointer; delete[] pointerToPointer; }}; int main(){ myClass myclass;...

Function- and Type substitutions or Views in Coq

list,heap,coq,isomorphism
I proved some theorems about lists, and extracted algorithms from them. Now I want to use heaps instead, because lookup and concatenation are faster. What I currently do to achieve this is to just use custom definitions for the extracted list type. I would like to do this in a...

Where is Heap and Stack on Physical Memory? [closed]

c++,memory,stack,heap
I read by some googling about Heap & Stack, but most answer says just its concept description, differences. I am curious other things. as title says, Where is Heap and Stack on Physical Memory? How is their size? For example, I use 12 giga byte memory at my desktop PC,...

how can i find which application is causing memory leaks

java,tomcat,memory-leaks,heap
I am running Tomcat-6.0.32 on the RHEL 5.4 with JDK-1.6.0_23 version. I am running almost more than 15 applications. Applications are small applications only. My RAM is 8GB and swap is 12GB. I set the heap size from 512Mb to 4GB. The issue is after a few hours or days...

MinHeap implementation in c# [closed]

c#,heap
I am working on a MinHeap implementation for school and I have encountered a problem. The code typically works well but sometimes generates an argument out of range exception in my heapify method. I have tried to isolate the problem but I am a terrible debugger. Here is my code...

When is my struct too large?

swift,class,struct,stack,heap
We're encouraged to use struct over class in Swift. This is because The compiler can do a lot of optimizations Instances are created on the stack which is a lot more performant than malloc/free calls The downside to struct variables is that they are copied each time when returning from...

What does '&' means on heap allocated pointers? [duplicate]

c++,heap,private-members
This question already has an answer here: C++ address operator uses? [duplicate] 3 answers I'm studying about accessing private class members. I would like to understand better about this. class Sharp { public: Sharp(); ~Sharp(); private: DWORD dwSharp; public: void SetSharp( DWORD sharp ) { dwSharp = sharp; };...

Understanding Stack, Heap and Memory Management

c++,pointers,memory-management,stack,heap
int *ip = new int[10]; for (int i = 0; i<10; i++) *(ip+i) = i; myfun(ip); // assume that myfun takes an argument of // type int* and returns no result delete [] ip; The above code is a small segment of a test function that I am trying to...

Compare value of std::shared_ptr in STL Heap and std::find. (Trying to implement A*)

c++,pointers,vector,heap,path-finding
TL;DR I have a vector of std::shared_ptr's that I have to run std::push_heap, std::pop_heap, and std::find on. How do I compare the the things the pointers are pointing to rather than the pointers themselves? Hi, I am trying to implement A* in my game and am having some trouble figuring...

An internal error occurred during: “Launching ”. Java heap space

java,android,eclipse,heap
When I run my Android app in Eclipse Juno it shows: An internal error occurred during: "Launching ". Java heap space". I have modified my eclipse.ini file with Xms:1024m Xmx:1024m Unfortunately this did not solve the problem....

How Does Windows Pick memory for threads?

c++,multithreading,memory,heap
My previous post,(Edit: Now solved) New Thread Corrupting String Data: C++ was too complicated it seems. So this is a more general post to answer my questions. If a thread is created inside a If, For, while, case, ect. Is the thread's heap a sub set of the memory allocated...

CLR Sync Block Address

c#,heap,clr
When I do: public class Employee { public int exp; } class Program { static void Main(string[] args) { Employee o1 = new Employee(); o1.exp = 3; lock (o1) { //I am here } } } and get memory of o1 (address is 0x022cf940): I realized couple of things mentioned...

w3wp.exe Garbage Heap is FULL of Free object space and keeps on growing

memory-leaks,garbage-collection,heap,w3wp.exe
My IIS app (.NET 4.0, IIS7) is continually growing in memory, and eventually falls over, as if I have a memory leak. So I took a DMP while it was up around 1.7GB and cracked it open in WinDbg. The dumpheap -stat command showed that while I had a fair...

Finding stack buffer overflows

c,memory,heap,stack-overflow,hacking
I have read 5 Papers/articles and 2 videos on Stack Buffer Overflows, and Heap overflows. I have written a program that was vulnerable overflowed and exploited that, ran a server on port 7777 that was vulnerable, overflowed and exploited that. But what I don't understand is how to find vulnerbilities...

Deleting the topmost element in the binary heap

c,arrays,heap
I'm trying to implement the binary heap. I've successfully implemented display() and insert() functions. Problem : Inside deleteHeap() function Approach 1.Copy the heap's root into a variable 2.Now copy the heap's last element into the root.Decrement the heap node count n 3.Now check if the property of heap is violated....

get the size of heap array in c++ [duplicate]

c++,arrays,heap
This question already has an answer here: Size of array (new[]) 4 answers Code1: int * a; a=new int[222]; cout<<"the size of a is "<<sizeof(a)<<endl; Output1: the size of a is 8 Code2: int * a; a=new int[222]; cout<<"the size of a is "<<a.length()<<endl; Output2: error: member reference base...

Windows Heap Chunk Header Parsing and Size Calculation

debugging,heap,reverse-engineering,windbg,heap-memory
How can I calculate heap chunk size from raw bytes read from memory. I tried below thing. 0:001> !heap Index Address Name Debugging options enabled 1: 00500000 2: 00280000 3: 008f0000 4: 00ab0000 5: 00cc0000 0:001> !heap -a 00500000 .. .. Heap entries for Segment00 in Heap 00500000 address: psize...

Can Fibonacci Heap have more than one nodes with equal rank(or value, or key)?

algorithm,heap,computer-science,fibonacci-heap
I am studying Fibonacci heap alone, and I came across a question. I know any nodes can be inserted into Fibonacci heap, but what if the rank(or value, or key) of that new node is equal to the sibling node? 1) For example, (1) <-minimum root / \ (3) (5)...

memory allocation - Java vs C++

java,c++,memory,heap
Given class Line in both java and C++, and the following declarations in java and C++ respectively - Line[] p; and Line *p; What are the differences in semantics between the two languages when then running the following code: p = new Line[7]; In particular, do both languages assign heap...

Out of Memory Error on High Resolution mobile phones

android,out-of-memory,heap
My application is running fine on tablets its taking memory very less about 20-30 MB as can be seen DBMS -> Debug & Heap tracker. But when running same application on Devices like Samsung Galaxy Note-4 (2560 x 1440) & LG G3 (2392 x 1440) its taking heap space of...

Would building a max heap from an Unsorted array would follow Binary Tree properties?

java,c,arrays,algorithm,heap
Given an unsorted array of size 10 int[] arr={∞,1,2,3,4,5,6,7,8,9,10}; If I execute code public void build_heap(){ for(int i=size/2;i>=1;i--) max_heapify(i); } The resulting array in what case follow binary tree properties ( ie left subtree < root & root < right subtree ) ? How to generate such an array ?...

How can I avoid a stack overflow when Fortran RESHAPE produces a large, internal, temporary array?

stack,fortran,heap,stack-overflow,reshape
I have some Fortran code that calls RESHAPE to reorder a matrix such that the dimension that I am now about to loop over becomes the first varying dimension (Column-major order in Fortran). This has nothing to do with C/Fortran interoperability. Now the matrix is rather large and when I...

How to get or store heap size in RtlAllocateHeap for later use in RtlFreeHeap?

c++,windows,heap,hook
The core problem: An old Windows XP game freezes on newer Windows versions unless it is run with Windows XP compatibility mode. Even through it is not essential to provide a code fix for this, I still like to make a fix for this freeze, because noobie users run in...

How to allocate arrays on the heap in Rust 1.0 (beta)?

arrays,heap,rust
There is already a question for this but related to Rust 0.13 and the syntax seems to have changed (?). From the current documentation I understood that creating an array on the heap would be something like this: fn main() { const SIZE: usize = 1024 * 1024; Box::new([10.0; SIZE]);...

Priority queue with O(1) Get-Min, Delete-Min and Merge operations

algorithm,heap,priority-queue,splay-tree
I'm wondering if there is a way to construct a priority queue structure that supports constant-time get-min, delete-min, and merge operations. I don't care about the time complexity of insertions and it doesn't have to support the decrease-key operation. My use case in (bad) pseudo-code: func periodical(current_state) { // always_executed_jobs...

Calling classes on the heap (null string error) C++

c++,class,oop,heap
I have a project for class where I'm taking a lovely list of 50 students, placing them on the heap, and then printing them, sorting, reprinting. I have to use OOP for this, which isn't a huge deal, but I'm struggling with connecting my base data classes to their parent...

What is the algorithm used by python's heapq.merge known as?

python,algorithm,merge,heap
From python docs. I have found the algorithm in quite a few places such as here, here and here. None of them have mentioned the name of the algorithm. I need to give a reference for a paper so please point me in the right direction....

How to make a stack grow dynamically?

c++,class,memory,stack,heap
Here is a little program with my Stack class: #include <iostream> using namespace std; #include <iomanip> template <typename T> class Stack { private: T *stackPtr; int size; T top; public: Stack(int = 10); ~Stack(); bool push(const T ); bool pop(); void printStack(); }; int main() { Stack <int> myStack(5); cout...

ARM Cortex-M heap alignment

heap,memory-alignment,cortex-m,eabi
After being bitten by stack alignment problems I started wondering whether the heap should be aligned to 8-octet boundaries, as well. The ARM Cortex EABI states that for all calls to external functions the stack has to be 8-aligned. I could not find any information on whether there are any...

Why isn't the z bubbling down in the min heap?

java,algorithm,tree,heap,binary-tree
I am working on a practice data structures problem from Heap Practice The objective is to make a constructor for a min heap with a given array. The author already gives us the high level algorithm to do so, "If you just "bubble down" all of the non-leaf nodes of...

Heap dump on JRE 6 (Windows) without JDK

java,memory-leaks,heap,dump
Is there a way to create a heap dump on a remote machine without JDK installed? I can't change the installation / settings and it's running on Windows. So I have pnly access to commandline tools. Problem is that a Java app on a remote machine freezes (no out of...

Using a Min-Heap to Sort Words

java,sorting,heap,min-heap
I am learning to use heaps and as an exercise I am trying to write a program using a heap class I have created to sort words. I have read in words from a file and added them to the heap successfully. I am having some trouble figuring out how...

In which memory is saving Java ClassLoader instance

java,heap,classloader,permgen
I want to know where the ClassLoader instance is saving, in which memory. Is it saving in heap or in permgen? And if I have a custom ClassLoader( for example JasperReports loads his own ClassLoader which calls JRClassLoader ), instance of it is also saving in heap memory or in...

I'm using minHeapify() to sort my array, and extractMin() please help debug

java,arrays,sorting,heap
I'm using minHeapify structure to extract numbers from an array, and uses this method "minHeapify()" to sort my array, and extractMin() to return the element with the lowest value. My problem is that it sorts somewhat alright, but it always return the first element first, and it is having trouble...

Why would one use a heap over a self balancing binary search tree?

data-structures,tree,heap,binary-search-tree,avl-tree
What are the uses of heaps? Whatever a heap can do can also be done by a self-balancing binary search tree like an AVL tree. The most common use of heap is to find the minimum (or maximum) element in O(1) time (which is always the root). This functionality can...

Priority Queue using a Max-Heap Data Structure

python,insert,heap,priority-queue,max-heap
I am implementing a priority queue using a max-heap data structure in Python. I'm using several names that have numbers associated with them as their priority (9 being the highest and 1 being the lowest). The issue I am facing is that when I dequeue an item from the priority...

WA_DeleteOnClose delete all members?

c++,delete,heap,qt5,destructor
I'm in trouble with Qt5's WA_DeleteOnClose attribute. This is the situation: I have a class M that extends QMainWindow, and in this class I use an heap-allocated array. I read that with WA_DeleteOnClose when the window M is closed, and the destructor called, every member with M as parent is...

How to share data (array) between recursive calls?

java,recursion,stack,heap
I know Each recursive call has its own copy of data stored in its reserved area in the stack. However how can a recursive call access shared public static data declared in the main for example ? Is this data in the stack or heap ?...

Java - Why is this implementation of a binary heap faster than the other?

java,performance,heap
After reading a bit about heaps/priority queues, I recently made my own implementation of one. Afterwards I decided to compare the performance of my implementation to that of one which I found in a book, and the results are a bit confusing to me. It appears that there is a...

How does the following comparator even works while building up the min heap?

c++,heap
I know that if I build a heap using STL, it makes a max_heap. And if I want to make a min_heap, I will have to write my own custom comparator. Now, the following comparator, struct greater1{ bool operator()(const long& a,const long& b) const{ return a>b; } }; int main()...

Can std::string reallocation invalidate pointer to heap?

c++,string,pointers,heap,invalidation
My question is regarding the following scenario: std::string *ps = new std::string(); *ps = aVeryLargeString; 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. So ps will still point to the new string as...

Heap size is greater than -Xmx

java,memory,garbage-collection,jvm,heap
I set the initial and maximum Java heap size to 256MB using -Xms256m and -Xmx256m JVM options. The GC log (using -XX:+PrintHeapAtGC) states that the heap size is 251904K (246MB), which is smaller than the minimum heap size, -Xms256m (see last line of log). However, this is because the stated...

Making a heap with list causes errors

c++,heap,containers
The following code: std::list<int> list; std::make_heap(list.begin(), list.end()); Live demo causes a whole bunch of errors, including: error: no match for 'operator-' When I declare list as std::vector, I do not get these errors, why?...

Is there any way to handle Java heap space exception [duplicate]

java,exception,heap
This question already has an answer here: How to deal with “java.lang.OutOfMemoryError: Java heap space” error (64MB heap size) 14 answers What is an OutOfMemoryError and how do I debug and fix it 4 answers I am looking to convert file input stream for big file (The file is...

Python: Using my heap in a priority queue implementation

python,heap,priority-queue,binary-heap
I am having real trouble using my custom-made heap class functions to be used in my Priority Queue class. I am having trouble on what functions from my heap class to use for my "enqueue", "dequeue", "front" and "size" functions for my PriorityQueue. I know for "enqueue" I need to...

String immutable? [duplicate]

java,string,stack,heap,immutability
This question already has an answer here: Immutability of Strings in Java [duplicate] 10 answers Can anyone answer me please? public class ReplaceString{ public static void main(String arg[]) { String a = "Hariom"; a = a.replace('H', 'b'); System.out.println(a); } } ...

Why return a pointer to a variable on the heap instead of the variable itself in C++

c++,pointers,stack,heap
So I'm coming from Java and am now learning C++, I understand how pointers work, what the stack and heap memory are and I have googled a lot but i can not seem to understand why we wouldn't just return the object itself instead of a pointer pointing to a...

How to configure java memory heap space for hadoop mapreduce?

java,hadoop,mapreduce,heap,shuffle
I've tried to run a mapreduce job on about 20 GB data, and I got an error on reduce shuffle phase. It says that because of memory heap space. Then, I've read on many source, that I have to decrease the mapreduce.reduce.shuffle.input.buffer.percent property on mapred-site.xml with the default value 0,7....

How many Strings are created in memory?

java,string,heap,concatenation,string-concatenation
Say I have this String expression String hi = "Tom" + "Brady" + "Goat" I know that the String pool "allows a runtime to save memory by preserving immutable strings in a pool" String Pool How many strings will be created in the string pool? My initial guess was 5...

Memory: Stack and Swap

linux,memory,stack,heap,swap
When there isn't enough RAM, dynamically allocated variables on the heap can take advantage of swap space on the disk (albeit causing performance degradations). My question is if the stack in memory can take advantage of the swap space as well. For example, the following program places a large array...

Questions about heaps in coursera's open course

algorithm,heap
Here are two questions that I got the wrong answer but I don't know why. 1.Suppose you implement the functionality of a priority queue using a sorted array (e.g., from biggest to smallest). What is the worst-case running time of Insert and Extract-Min, respectively? (Assume that you have a large...

Allocated on the heap or the stack? [closed]

c#,memory,stack,heap
I recently asked a question about StackOverflowExeptions and the explanations were very helpful! However, I wrote a method and tried to figure out where T cached is allocated (heap/stack): private Dictionary<Type, Component> _cachedComponents = new Dictionary<Type, Component>(); public T GetCachedComponent<T>() where T : Component { //Not yet sure if the...

where to declare object to use it (fltk)

c++,stack,heap,fltk
I am having a problem accessing an object or its methods in fltk. I have a Class named MyWindow which is a child class of Fl_Window. so basically i would like to use an object which is either declared int the main or Mywindow in private section. My problem is...

How to find memory leaks using app dynamics

jvm,heap,heap-memory,appdynamics
Could anyone explain me how to find memory leaks with the help of app dynamics.I tried to search but could not find any proper answer.

Big-O of Dijkstra's Algorithm with D-Ary Heap

algorithm,heap,big-o,dijkstra
I'm looking for a complete walkthrough on the runtime of Dijkstra's algorithm when implemented with a D-Ary heap. My best understanding as of now is that the depth of the tree is at most log_d(n), so the max time of insertion and bubbling up is log_d(n). Wouldn't bubble down be...

Where exactly is this object being stored? (Swift)

function,swift,memory,stack,heap
Consider the following code: class Foo { } func foo() -> (Void -> Foo) { var foo = Foo() return { foo } } var fooGen = foo() Now whenever I call fooGen, I get my stored Foo instance. But where exactly is foo being stored? Is it inside the...

std::push_heap and std::pop_heap with MoveConstructible objects

c++,c++11,stl,heap,move-semantics
I want to maintain a heap where the payloads are MoveConstructible (because they hold a std::unique_ptr inside.) Although the documentation suggests that the object must be MoveAssignable and MoveConstructible, doing so throws an error both in GCC and Clang. Sample Code I don't use an std::unique_ptr yet, but just disable...

How does java reference objects vs variables

java,heap
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package corejava; /** * * @author Administrator */ public class CoreJava { /** * @param args the command line arguments */ public static void main(String[] args) { Test test=new Test(); test.setx(20);...

Convert from max heap to min heap

heap
Got this heap: 10 / \ 9 8 / \ / \ 7 6 5 4 / \ / 3 2 1 And i'm going to show each step when i convert it to a minimum heap from maximum. I'm not sure how i do it, any help please? Thanks....