heap

Debug Visual C++ memory allocation problems

自作多情 提交于 2019-12-20 06:11:15
问题 I'm debugging a software which crashes eventually with one of the following messages: 1. DAMAGE: after normal block (#24729280) at 0x00D710E0 2. Debug Assertion Failed Program: D:\Soft\Test.exe File: dbgheap.c Line: 1017 Expression: _BLOCK_TYPE_IS_VALID(phead->nBlockUse) This software is really old but changing it now is not an option. It's written on Visual C++ 6.0. We are guessing it's some kind of buffer overflow, so we are trying to find ways to detect where it is happening. I have found

C implementation of skew heap

点点圈 提交于 2019-12-20 04:39:11
问题 I'm trying to implement a skew heap in C, but my code doesn't compile. I'm not that experienced in C and never created any type of heap in C. That is why I don't know how to fix it, I'm hoping someone can point me the right direction. I have been reading articles about the skew heap and this is what I got so far using the algorithms I have found online. Thanks in Advance. typedef struct node { int value; struct node * root; struct node * leftchild; struct node * rightchild; } Node; struct

AVL Binary Heap(Balanace test)

孤人 提交于 2019-12-20 04:25:07
问题 I'm trying to achieve a testing if a tree is AVL tree or not using prolog. I've made a height test that works for the tests I've done so far but my balancing test is still not going strong. This is my work so far: avl('Branch'(LeftBranch,RightBranch)) :- height(LeftBranch,H1), height(RightBranch,H2), abs(H1-H2) =< 1. I've based this code from an older stackoverflow code. But it doesn't work in all cases. Will include my height code. Somewhere I've made a misstake and Im sure where to find it.

max_heapify procedure on heap

谁都会走 提交于 2019-12-20 03:06:50
问题 i have these procedure #include <iostream> using namespace std; int parent(int i ){ return i/2; } int left(int i ){ return 2*i; } int right(int i){ return 2*i+1; } int a[]={ 27,17,3,16,10,1,5,7,12,4,8,9,10}; int n=sizeof(a)/sizeof(int); void max_Heapify(int i){ int largest=0; int l=left(i); int r=right(i); if(l<=n && a[l]>a[i]){ largest=l; } else{ largest=i; } if(r< n && a[r]>a[largest]){ largest=r; } if (largest!=i){ int t=a[i]; a[i]=a[largest]; a[largest]=t; } max_Heapify(largest); } int

C++ Size Of Dynamic Memory at Runtime

拈花ヽ惹草 提交于 2019-12-19 18:26:50
问题 This is something I've been wondering for a while and never found an answer for: Why is it that when you allocate something on the heap you cannot determine the size of it from just the pointer, yet you can delete it using just the pointer and somehow C++ knows how many bytes to free? Does this have something to do with the way it is stored on the heap? Is this information there but not exposed by C++? And perhaps this should be a separate question but I think it's pretty related so I'll ask

C++ Size Of Dynamic Memory at Runtime

久未见 提交于 2019-12-19 18:25:21
问题 This is something I've been wondering for a while and never found an answer for: Why is it that when you allocate something on the heap you cannot determine the size of it from just the pointer, yet you can delete it using just the pointer and somehow C++ knows how many bytes to free? Does this have something to do with the way it is stored on the heap? Is this information there but not exposed by C++? And perhaps this should be a separate question but I think it's pretty related so I'll ask

Windows Heap Chunk Header Parsing and Size Calculation

北城以北 提交于 2019-12-19 07:50:47
问题 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 . size flags state (requested size) 00500000: 00000 . 00588 [101] - busy (587) 00500588: 00588 . 00240 [101] - busy (23f) 005007c8: 00240 . 00020 [101] - busy (18) 005007e8: 00020 . 00ca0 [101] -

Windows Heap Chunk Header Parsing and Size Calculation

落爺英雄遲暮 提交于 2019-12-19 07:50:31
问题 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 . size flags state (requested size) 00500000: 00000 . 00588 [101] - busy (587) 00500588: 00588 . 00240 [101] - busy (23f) 005007c8: 00240 . 00020 [101] - busy (18) 005007e8: 00020 . 00ca0 [101] -

is there a point in recycling value types unity

杀马特。学长 韩版系。学妹 提交于 2019-12-19 07:36:42
问题 I found article stating that recycling and reusing variables is good practice in unity. So I adopted it. But one thing not clear : does this apply to value type variables (integers, vectors)? is there a point i using this: int x; Vector3 v; void functionCalledVeryOften(){ x=SomeCalculation(); v=SomeCalc(); //do something with x and v } instead of this: void functionCalledVeryOften(){ int x=SomeCalculation(); Vector3 v=SomeCalc(); //do something with x and v } 回答1: This is fairly dependent on

What happens in the heap when class A inherits class B in Java

萝らか妹 提交于 2019-12-19 05:37:30
问题 In Java suppose we have two classes A and B such that B inherits A and A has three private fields and a constructor with three parameters: public class A { private int a ; private int b ; private int c ; public A(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } } and here is class B public class B extends A { public B() { super(1,2,3); } } We consider the following test class public class TestA { public static void main(String[] args) { A a = new A(1,2,3); B b = new B(); } } The