FAQ Database Discussion Community

Is an attempt to modify a const_cast-ed, but dynamically allocated constant object still undefined behavior? [duplicate]

This question already has an answer here: Can a heap-allocated object be const in C++? 6 answers For example: const int* pc = new const int(3); // note the const int* p = const_cast<int*>(pc); *p = 4; // undefined behavior? In particular, can the compiler ever optimize away the...

Access the memory values (as ruby objects) inside a running Ruby program?

There's a great program called Hijack that lets you get an irb shell for a running ruby process, but it doesn't seem compatible with newer version of ruby. Are there any known alternatives? I'm thinking maybe something like strace/dtrace if I want to get really hardcore. It wouldn't get me...

Memory management in Contiki-OS

I am trying to create a port for Contiki-os to LPC1347, and i have a question as to how exactly is memory handled in Contiki. Protothreads are stack-less and no "real threads" are used so everything is basically on the same stack, so it is basically static memory allocation. I...

NETBEANS: “java.lang.OutOfMemoryError: Java heap space” [duplicate]

This question already has an answer here: How to deal with “java.lang.OutOfMemoryError: Java heap space” error (64MB heap size) 14 answers I encountered an error in Netbeans: java.lang.OutOfMemoryError: Java heap space This is the first time I encountered this and I don't know how to deal with it. Can...

memory corruption error during allocation

my code in C++ using QT gives me memory corruption error when I go through this part of the code: for (int vid=0;vid<m_trajs.size();vid++) { QVector<int*> clusterIDs_foronevideo; for (int level=0;level<nbClusters.size();level++) { int* clusterIDs_atonelevel = new int [long_vals[vid]]; for (int ind=0;ind<stInd[vid];ind++) { clusterIDs_atonelevel[ind] = clusterIDs[level][ind]; } clusterIDs_foronevideo << clusterIDs_atonelevel; } m_clusterIDs <<...

Strange error while adding a feature to my little game (0xC0000005)

Hello everyone, I decided some time ago to write my own version of Minesweepers as some practice and I did it. The game ran perfectly, but after deciding to add a "Choose difficulty" option the window freezes and I get an error message, saying that the program does not respond....

How do I release images and avoid outOfMemory exc-n when navigating back and forth between activities[android]

I have a children tale app - 18 pages, each page is an activity with a background image, short story and sound for every word(textView) in a story, and some animations. I notice, when i go to next page, the memory is consumed; it is also consumed when i go...

Call-by-value of a c struct containing a pointer to heap allocated memory

Dear stackoverflowers. During some experimenting with c and structs, me and a friend of mine came across something we cannot quite get our heads around. Below is a code snippet describing a struct with an int pointer and a variable. They are both set whilst creating the struct in the...

How to increase Java heap space on Spark Amazon EC2 cluster?

I wrote a program using Java Spark API. Given my data is big, I am getting the following error java.lang.OutOfMemoryError: Java heap space Any idea how to increase java heap space of Spark EC2 cluster on Aws? I can give details about my code and cluster setup if necessary. Thanks....

Heap memory consumed more than committed memory

Can heap memory increase beyond the cap of -Xmx memory? I have -Xmx set to 1G. The profiling screenshot captured from JProfile shows the heap growing beyond 1G and sometime doubling to 2G. What then is the meaning of -Xmx ? ...

How to set Java heap size (Xms/Xmx) inside Docker container?

As of raising this question, Docker looks to be new enough to not have answers to this question on the net. The only place I found is this article in which the author is saying it is hard, and that's it.

Thread '
' has overflowed its stack when allocating a large array using Box

I'm trying to create fixed-size array in stack, but it shows stack overflow, then I change it to heap (it said to allocate in the heap we must use box), but it still shows an stack overflow. fn new_gap(gap: usize) -> usize { let ngap = ((gap as f64) /...

Mutex assertion error with non-zero heap

If I allocate memory, free it and then try to allocate a mutex and lock it, I get the message Assertion 'mutex->__data.__owner == 0'. I am not an expert in concurrency or low-level programming but this seems odd to me. Code #include <stdlib.h> #include <string.h> #include <pthread.h> void nonzero_heap(){ void...

C++ Pointer Object Location

I have the following C++ code: struct B { int c; int d; } struct A { int a; B x; } int main() { A * ptr = new A; ptr->a = 1; ptr->x.c = 2; ptr->x.d = 23; // a lot of lines of codes later ... //...

create vector of objects on the stack ? (c++)

I am creating a temporary vector of pointers to myObject objects. But I am wondering about what happens to the objects I created... { std::vector<myObject *> myVector; myVector.reserve(5); for (int i = 0 ; i < 5 ; ++i){ myVector[i] = new myObject(); } } I assume that at the...

Unable to process large PDF file

I have jave file with size 160MB. When I try to load it in PdfReader (Itext Library) it fire following error: java.io.IOException: Not enough storage is available to process this command I am using Java Version 1.5 (32bit). Code: PdfReader pdfReader = null; try{ pdfReader = new PdfReader("D://bigfile.pdf"); //also try...

Infinite loop without accepting input

I am writing a simple C++ Program which allocates dynamic memory to my Program and then deletes this memory. Here is my Program: #include <iostream> #include <new> using namespace std; int main () { int i,n; int * p; cout << "How many numbers would you like to type? ";...

How to handle “[ERROR] Exception in thread ”main“ java.lang.OutOfMemoryError: Java heap space” in JENKINS?

I have been building GWT war file on Jenkins. In a specific "job" I have encountered an error which says [ERROR] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space. As a solution, I have included an environment variable "MAVEN_OPTS" with a value of -Xms512m -Xmx1024m -XX:MaxPermSize=512m. FYI, I have also...

How to find memory leaks using app dynamics

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.

TaskManager android that will show current memory usage and cpu usage

I am making a Project on TaskManager android just like windows Taskmanager. How to get CPU usage and memory Usage?

uninitialized data segment of program memory

In Uninitialized Data Segment, the kernel initialize the uninitialized variable to 0. But if we directly use an uninitialized variable (for eg. int sum; and not int sum=0; ) and use it in program like sum=sum+n(n be any number), sum will take any garbage value. So why the sum will...

Windows Heap Chunk Header Parsing and Size Calculation

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...

My Mac is not taking my Heap Size configurations

I'm trying to work with thousands of live objects on my Mac. I tried to change the heap size in the eclipse.ini to 2G but according to my jconsole Java is still limiting to 130mb and throwing Java Heap Space error out of memory. It seems that Java doesn't take...

Why in C++ overwritingis is slower than writing?

I have to run a piece of code that manages a video stream from camera. I am trying to boost it, and I realized a weird C++ behaviour. (I have to admit I am realizing I do not know C++) The first piece of code run faster than the seconds,...

Tomcat Permgen not increased even if I put it in Java options

I'm running Tomcat 7 as a windows service in a Windows Server 2008 Machine. I've got a Java.lang.OutOfMemoryError: PermGen space so I'm trying to increase its PermGen memory heap. So I specify this line at the end of JVM options: -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+HeapDumpOnOutOfMemoryError As specified in the picture...

If “Heap” memory usage shown in JConsole usually returns to 0 after GC, is there no memory leak?

I've been trying to use JConsole to identify whether or not I have a memory leak. I let my code run for a long time, and ensure it performs many iterations of all functions available, starting/ stopping all threads many times, instantiating and releasing every object many times, encountering as...

Predictionio evaluation fails with empty.maxBy exception and training with java.lang.OutOfMemoryError

I have downloaded the latest update on text classification template. I created a new app and imported stopwords.json and emails.json by specifying app id $ pio import --appid <appID> --input data/stopwords.json $ pio import --appid <appID> --input data/emails.json Then I changed engine.json and given my app name in it. {...

Category implementation stuck in thread with increasing memory heap space

I am learning Categories in Objective-C. I am trying to write a sample program with categories in XCode and the program execution hangs on one line as shown in the image, but the memory keeps increasing. I hope that someone can help. I have attached snapshot below. The source code...

Why doesn't malloc allocate memory at all?

I have the following struct: struct block { void *addr; /*start address of memory for this block */ int size; struct block *next; }; I have the following code to initialize each block: void block_init(struct block *b, void *addr, int size){ /*Allocate space and fill b with the initial data.*/...

c++ dynamically declared array fails to work

I am trying to read the file's data into a dynamically declared array, using double *data = new double[14141414]() declaration. Note, it is rather a large file; hence large size of an array. The problem is I can not put all the data into an array as somewhere around index=14000000...

CUDA memory access violation when creating an object in kernel function

To allocate a large memory in CUDA kernel function using operator new I set the value of cudaLimitMallocHeapSize to the size of free device memory ~1.7-1.8G at every launch. But if I try to create an object in kernel function I get a memory access violation in the line i...