18
голосов
5ответов
61868 просмотров

Creating array of objects on the stack and heap

Consider the following code: class myarray { int i; public: myarray(int a) : i(a){ } } How can you create an array of objects of myarray on the stack and how can you create an array of objects on the heap?

25
голосов
3ответов
29871 просмотров

Algorithm for merging two max heaps?

Is there an efficient algorithm for merging 2 max-heaps that are stored as arrays?

8
голосов
6ответов
4612 просмотров

How to detect and estimate heap fragmentation in my C++ program?

I'm developing a VC++ NT service that is meant to operate continuously for many months. It uses VC++ runtime heap intensively. Clearly heap fragmentation can at some point cause it malfunctioning (thinking it's out of memory). What tests can I run on my service to estimate the degree it is prone...

1
голосов
4ответов
3555 просмотров

Check Spelling program in C

I'm a beginner to C programming. I'm trying to learning how to code a spell checker that looks through all the words in a dictionary file, compare them with an article, print out all the words that do not exist in the dictionary file onto the console. Since I'm studying malloc in class, I've lowe...

1
голосов
6ответов
2664 просмотров

Populating Heap (malloc) with a string array

i'm trying to populate the heap with a string array, but the console gave me nothing when i compiled. I don't know what I did wrong... void spellCheck(char article[], char dictionary[]) { int i = 0; char* tempArticle; while ( article[i] != '12321'){ i++; } tempArticle...

2
голосов
2ответов
7046 просмотров

What's the default heap size for IBM's J9VM?

I have IBM's J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3) installed. After getting an OOM, the size of the heap dump is 383MB. How much heap does the JVM have? The reason why I ask is that a 400MB heap dump seems a bit much for the default 64MB heap that I expect but I didn't specify any -Xm options...

3
голосов
1ответов
2401 просмотров

Can you extract the value of strings from an IBM PHD java heap dump?

I have a PHD format heap dump from an IBM jvm and I wish to examine the values of some strings. With the Sun JVM's binary hprof dumps this is possible, but I haven't been able to recover this information from an IBM dump. I've tried: Eclipse Memory Analyzer (0.8.0.200906170940) with IBM's DTFJ...

14
голосов
7ответов
8140 просмотров

Stack vs. Heap in .NET

In your actual programming experience, how did this knowledge of STACK and HEAP actually rescue you in real life? Any story from the trenches? Or is this concept good for filling up programming books and good for theory?

22
голосов
9ответов
14853 просмотров

Why would you ever want to allocate memory on the heap rather than the stack?

Possible Duplicate: When is it best to use a Stack instead of a Heap and vice versa? I've read a few of the other questions regarding the heap vs stack, but they seem to focus more on what the heap/stack do rather than why you would use them. It seems to me that stack allocation would a...

4
голосов
2ответов
419 просмотров

When happens to value types when they're removed from a collection?

Suppose I have some simple struct like this: public struct WeightedInt { public int value; public double weight; } Then let's say I have a collection of instances of this structure: List<WeightedInt> weightedInts = new List<WeightedInt>(); As I understand value types ver...

5
голосов
6ответов
9815 просмотров

Java memory mystery (do I have a leak)?

I have a standalone Java problem running in a linux server. I started the jvm with -Xmx256m. I attached a JMX monitor and can see that the heap never really passes 256Mb. However, on my linux system when I run the top command I can see that: 1) First of all, the RES memory usage of this process ...

1
голосов
2ответов
101 просмотров

Why is the size of my HeapOverflow program 5MB?

So I was asking myself what would happen if I tried to do a heap overflow on Windows XP, and I was surprise to see that, once the program "ate" all the RAM (this happens instantly, by the way), the size of the process in the task manager goes down to 5MB and doesn't move afterwards. The computer ...

37
голосов
4ответов
16338 просмотров

How can I implement decrease-key functionality in Python's heapq?

I know it is possible to realize decrease-key functionality in O(log n) but I don't know how?

4
голосов
3ответов
2308 просмотров

Portable way to detect heap fragmentation in c++ at runtime?

I'm writing a qt-based c++ application and i need to be able to detect memory fragmentation in order to check if the current system can actually sustain the memory load: the program load a big image (15/21 megapixels are the norm) in memory and then perform some filtering on it (w/ sparse matrice...

8
голосов
5ответов
4084 просмотров

Defragmenting C++ Heap Allocator & STL

I'm looking to write a self defragmenting memory manager whereby a simple incrementing heap allocator is used in combination with a simple compacting defragmenter. The rough scheme would be to allocate blocks starting at the lowest memory address going upwards and keeping book-keeping informat...

1
голосов
2ответов
1145 просмотров

How to avoid "(null)" StackTrace in DPH_BLOCK_INFORMATION?

I'm having a blast tracking down some heap corruption. I've enabled standard page heap verification with gflags /p /enable myprogram.exe and this succeeds in confirming the corruption: =========================================================== VERIFIER STOP 00000008: pid 0x1040: corrupted su...

50
голосов
5ответов
26087 просмотров

Increase JVM heap size for Scala?

I have a Scala data processing tool which is failing with a java.lang.OutOfMemoryError exception. The tool needs to make a couple passes over a large data file (the one I'm working on is over 700MB), so it would be convenient if the entire thing could be stored in memory. I run the tool from the...

-10
голосов
2ответов
371 просмотров

Which object is created in which part of memory?

public class Order { static Customer cust = new Customer(); string sEmpty = ""; public static void main(String args[]) { int iTotal = 10; string sProductName = "Salt"; Ship shp = new Ship(); } } At the above code, which object and reference is create...

1
голосов
3ответов
633 просмотров

How to do memory analysis of heap allocated objects in an embedded systems?

I'm trying to analyze the memory usage of our systems. We have some singleton objects that are allocated on the heap at start-up. I would like to get the size of those objects. The information has to be there, since the debugger knows how big they are. How can I dump that info out of dwarf2 debug...

4
голосов
3ответов
977 просмотров

Heap Dump Root Classes

We have production system going into infinite loop of full gc and memory drops form 8 gigs to like 1 MB in just 2 minutes. After taking heap dump it tells me there an is an array of java.lang.Object ([Ljava.lang.Object) with millions of java.lang.String objects having same String taking 99% of h...

3
голосов
3ответов
5774 просмотров

How can I access Java heap objects without a reference?

I would like to get a reference to all objects in the Java heap, even if I don't immediately have a reference to those objects in my active thread. I don't need non-referenced objects (those "queued" for garbage collection), but would like to get anything that's still in use. The goal is to ser...

-1
голосов
2ответов
1434 просмотров

Extract min implemetation for heap in c++

I need to implement extract min for heap(in c++ if possible), could not get this method from STL heap.

2
голосов
1ответов
1139 просмотров

Fibonacci Heap Issue

I've been working on a Fibonacci Heap implementation in Java for about a week now. It's the implementation based off of the CLRS book. I wanted to see if I would get any performance boost using it in a side project I'm working on compared to Java's default PriorityQueue. [The default implementat...

3
голосов
1ответов
1924 просмотров

LuaJit increase stack/heap size

I keep getting a out of memory error in LuaJit. How do I increase the stack or heap size? Thanks

7
голосов
3ответов
7442 просмотров

max heap usage allowed per process

i m using malloc to allocate memory and memory requirements are greater than 1GB. so program is crashing... i want to ask whether this problem can be solved??If yes than how?? my RAM size is 3GB and using 32 bit windows os and programming using vc++

4
голосов
2ответов
330 просмотров

Find mapping between Windows heap and modules

I am searching for a way to find a mapping between a heap and the module which owns the heap. I retrieve the heaps in the following way: HANDLE heaps[1025]; DWORD nheaps = GetProcessHeaps((sizeof(heaps) / sizeof(HANDLE)) - 1, heaps); for (DWORD i = 0; i < nheaps; ++i) { // find module which...

28
голосов
3ответов
27274 просмотров

SQL Server heap v.s. clustered index

I am using SQL Server 2008. I know if a table has no clustered index, then it is called heap, or else the storage model is called clustered index (B-Tree). I want to learn more about what exactly means heap storage, what it looks like and whether it is organized as "heap" data structure (e.g. mi...

7
голосов
5ответов
1821 просмотров

Stack Frame Question: Java vs C++

Q1. In Java, all objects, arrays and class variables are stored on the heap? Is the same true for C++? Is data segment a part of Heap? What about the following code in C++? class MyClass{ private: static int counter; static int number; }; MyClass::number = 100; Q...

61
голосов
6ответов
15937 просмотров

What Happens When Stack and Heap Collide

I am curious to know what happens when the stack and the heap collide. If anybody has encountered this, please could they explain the scenario.

8
голосов
1ответов
2779 просмотров

Using Heapy's Memory Profile Browser with Twisted.web

I am trying to profile twisted python code with Heapy. For example (pseudo code): from twisted.web import resource, server from twisted.internet import reactor from guppy import hpy class RootResource(resource.Resource): render_GET(self, path, request): return "Hello World" if __n...