Search Results

Search found 960 results on 39 pages for 'heap'.

Page 3/39 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Re-adjusting a binary heap after removing the minimum element

    - by BeeBand
    After removing the minimum element in a binary heap, i.e. after removing the root, why is the last leaf then assigned to the root and sifted down? Why not take the lesser child of what used to be the root and just keep sifting up all the children? Isn't this the same amount of operations, so why is the "sift down" method preferred?

    Read the article

  • Using HeapDumpOnOutOfMemoryError parameter for heap dump for JBoss

    - by EdC
    I was told I can add the -XX:+HeapDumpOnOutOfMemoryError parameter to my JVM start up options to my JBoss start up script to get a heap dump when we get an out of memory error in our application. I was wondering where this data gets dumped? Is it just to the console, or to some log file? If it's just to the console, what if I'm not logged into the unix server through the console? Thanks

    Read the article

  • Compute jvm heap size to host web application

    - by Enrique
    Hello, I want to host a web application on a private JVM they offer 32, 64, 128, 256 MB plans. My web application uses Spring. And I store some objects for every logged in user session. My question is: How can I profile my web app to see how much heap size it needs so I can choose a plan?, How can I simulate hundreds of users logged in at the same time? I'm developing the application using Netbeans 6.7 Java 1.6 Tomcat 6.0.18 Thank you.

    Read the article

  • returning a heap block by reference in c++

    - by basicR
    I was trying to brush up my c++ skills. I got 2 functions: concat_HeapVal() returns the output heap variable by value concat_HeapRef() returns the output heap variable by reference When main() runs it will be on stack,s1 and s2 will be on stack, I pass the value by ref only and in each of the below functions, I create a variable on heap and concat them. When concat_HeapVal() is called it returns me the correct output. When concat_HeapRef() is called it returns me some memory address (wrong output). Why? I use new operator in both the functions. Hence it allocates on heap. So when I return by reference, heap will still be VALID even when my main() stack memory goes out of scope. So it's left to OS to cleanup the memory. Right? string& concat_HeapRef(const string& s1, const string& s2) { string *temp = new string(); temp->append(s1); temp->append(s2); return *temp; } string* concat_HeapVal(const string& s1, const string& s2) { string *temp = new string(); temp->append(s1); temp->append(s2); return temp; } int main() { string s1,s2; string heapOPRef; string *heapOPVal; cout<<"String Conact Experimentations\n"; cout<<"Enter s-1 : "; cin>>s1; cout<<"Enter s-2 : "; cin>>s2; heapOPRef = concat_HeapRef(s1,s2); heapOPVal = concat_HeapVal(s1,s2); cout<<heapOPRef<<" "<<heapOPVal<<" "<<endl; return -9; }

    Read the article

  • Threading heap and stack

    - by DJ
    How memory is allocated in case of spawning a new thread, i.e how memory heap, memory stack, and threads are related? I know this is fundamental (.net framework concept) but somehow I am not much aware of this concept.

    Read the article

  • Send a variable on the heap to another thread

    - by user1201889
    I have a strange problem in C++. An address of a Boolean gets "destroyed" but it doesn't get touched. I know that there are beater way's to accomplish what I try to do, but I want to know what I do wrong. I have a main class; this main class contains a vector of another class. There is a strange problem when a new instance gets created of this object. This is how my code works: There will start a thread when the constructor gets called of the “2nd”object. This thread gets as Parameter a struct. This is the struct: struct KeyPressData { vector<bool> *AutoPressStatus; vector<int> *AutoPressTime; bool * Destroy; bool * Ready; }; The struct gets filled in the constructor: MultiBoxClient::MultiBoxClient() { //init data DestroyThread = new bool; ReadyThread = new bool; AutoThreadData = new KeyPressData; //Reseting data *DestroyThread = false; *ReadyThread = false; //KeyPressData configurating AutoThreadData->AutoPressStatus = &AutoPressStatus; AutoThreadData->AutoPressTime = &AutoPressTime; AutoThreadData->Destroy = DestroyThread; AutoThreadData->Ready = ReadyThread; //Start the keypress thread CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)AutoKeyThread,AutoThreadData,NULL,NULL); } As long as the constructor is running will the program run fine. But when the constructor closes the address of the “AutoThreadData-Destroy” will get corrupted. The program will crash when I call the value of the pointer. void WINAPI AutoKeyThread(void * ThreadData) { KeyPressData * AutoThreadData = (KeyPressData*)ThreadData; while(true) { if(*AutoThreadData->Destroy == true) //CRASH { *AutoThreadData->Ready = true; return; } Sleep(100); } } What did I test: I logged the address of the AutoThreadData and the AutoThreadData-Destroy when the constrcutor is running and clossed; the AutoThreadData address is equal to AutoThreadData when the constructor is closed. So there is no problem here. The address of AutoThreadData-Destroy gets destroyed when the constructor is closed. But how can this happen? The Boolean is on the heap and the KeyPressData struct (AutoThreadData) is on the heap. Destroy before: 00A85328 Destroy after: FEEEFEEE Can someone maby explain why this crash? I know that I can send a pointer to my class to the thread. But I want to know what goes wrong here. That way I can learn from my mistakes. Could someone help me with this problem? Thanks!

    Read the article

  • Question about unions and heap allocated memory

    - by Dennis Miller
    I was trying to use a union to so I could update the fields in one thread and then read allfields in another thread. In the actual system, I have mutexes to make sure everything is safe. The problem is with fieldB, before I had to change it fieldB was declared like field A and C. However, due to a third party driver, fieldB must be alligned with page boundary. When I changed field B to be allocated with valloc, I run into problems. Questions: 1) Is there a way to statically declare fieldB alligned on page boundary. Basically do the same thing as valloc, but on the stack? 2) Is it possible to do a union when field B, or any field is being allocated on the heap?. Not sure if that is even legal. Here's a simple Test program I was experimenting with. This doesn't work unless you declare fieldB like field A and C, and make the obvious changes in the public methods. #include <iostream> #include <stdlib.h> #include <string.h> #include <stdio.h> class Test { public: Test(void) { // field B must be alligned to page boundary // Is there a way to do this on the stack??? this->field.fieldB = (unsigned char*) valloc(10); }; //I know this is bad, this class is being treated like //a global structure. Its self contained in another class. unsigned char* PointerToFieldA(void) { return &this->field.fieldA[0]; } unsigned char* PointerToFieldB(void) { return this->field.fieldB; } unsigned char* PointerToFieldC(void) { return &this->field.fieldC[0]; } unsigned char* PointerToAllFields(void) { return &this->allFields[0]; } private: // Is this union possible with field B being // allocated on the heap? union { struct { unsigned char fieldA[10]; //This field has to be alligned to page boundary //Is there way to be declared on the stack unsigned char* fieldB; unsigned char fieldC[10]; } field; unsigned char allFields[30]; }; }; int main() { Test test; strncpy((char*) test.PointerToFieldA(), "0123456789", 10); strncpy((char*) test.PointerToFieldB(), "1234567890", 10); strncpy((char*) test.PointerToFieldC(), "2345678901", 10); char dummy[11]; dummy[10] = '\0'; strncpy(dummy, (char*) test.PointerToFieldA(), 10); printf("%s\n", dummy); strncpy(dummy, (char*) test.PointerToFieldB(), 10); printf("%s\n", dummy); strncpy(dummy, (char*) test.PointerToFieldC(), 10); printf("%s\n", dummy); char allFields[31]; allFields[30] = '\0'; strncpy(allFields, (char*) test.PointerToAllFields(), 30); printf("%s\n", allFields); return 0; }

    Read the article

  • Huge file in Clojure and Java heap space error

    - by trzewiczek
    I posted before on a huge XML file - it's a 287GB XML with Wikipedia dump I want ot put into CSV file (revisions authors and timestamps). I managed to do that till some point. Before I got the StackOverflow Error, but now after solving the first problem I get: java.lang.OutOfMemoryError: Java heap space error. My code (partly taken from Justin Kramer answer) looks like that: (defn process-pages [page] (let [title (article-title page) revisions (filter #(= :revision (:tag %)) (:content page))] (for [revision revisions] (let [user (revision-user revision) time (revision-timestamp revision)] (spit "files/data.csv" (str "\"" time "\";\"" user "\";\"" title "\"\n" ) :append true))))) (defn open-file [file-name] (let [rdr (BufferedReader. (FileReader. file-name))] (->> (:content (data.xml/parse rdr :coalescing false)) (filter #(= :page (:tag %))) (map process-pages)))) I don't show article-title, revision-user and revision-title functions, because they just simply take data from a specific place in the page or revision hash. Anyone could help me with this - I'm really new in Clojure and don't get the problem.

    Read the article

  • java cannot reserver heap size error on windows server

    - by Prad
    HI, I have the following configuration: Server : windows 2003 server (32 bit) java version: 1.5_0_22 I get the following error when executing from command line ( my code is based off eclipse wihch gives the same error) java -XX:MaxPermSize=256m -Xmx512m Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. The server has over 20GB physical memory with over 19 GB free right now. It does not give an error upto -Xmx486m I have read other articles about contiguous memory space. There is hardly anything running on this server. Can I validae this in any way? Thanks

    Read the article

  • Initialization of array on heap

    - by Radek Šimko
    How do i manually initiate values in array on heap? If the array is local variable (in stack), it can be done very elegant and easy way, like this: int myArray[3] = {1,2,3}; Unfortunately, following code int * myArray = new int[3]; myArray = {1,2,3}; outputs an error by compiling error: expected primary-expression before ‘{’ token error: expected `;' before ‘{’ token Do i have to use cycle, or not-so-much-elegant way like this? myArray[0] = 1; myArray[1] = 2; myArray[2] = 3;

    Read the article

  • Deleting Part of An Array in Java to Free Memory on Heap

    - by kate
    I am implementing a dynamic programming algorithm for the knapsack problem in Java. I declare the array and then initialize its size to be [number of objects][capacity of knapsack]. When my number of objects or my capacity gets too large, I get a memory error because I run out of space on the heap. My questions is: If I delete rows from my double array as I go along, will Java free the memory as I delete? Or does Java reserve that memory space for the size of the array I originally created? If it's the latter, is there a way to manually free the memory in Java? Thanks for your Help!

    Read the article

  • Heap Error in C++

    - by BobAlmond
    Dear all, I'm a beginner programmer in C++. Recently, I'm working on image processing thing using C++. but I have some problem that I want to ask. Suppose I have some code as follow: for (int i=0;i<100000;i++) { int * a = new int[10000]; //do something delete [] a; } When I executed that code, I receive runtime error, Heap Error... Is there anything wrong with that code, I mean, can I allocate memory and release it in the same loop? Thanks in advance...

    Read the article

  • Closest location - Heapify or Build-heap

    - by Trevor Adams
    So lets say we have a set of gps data points and your current location. If asked to give the closest point to your current location we can utilize a heap with the distance being the key. Now if we update the current location, I suspect that only a few of the keys will change enough to violate the heap property. Would it be more efficient to rebuild the heap after recalculating the keys or to run heapify (assuming that only a few of the keys have changed enough). It is assumed that we don't jump around with the new location (new current location is close to the last current location).

    Read the article

  • android compile error: could not reserve enough space for object heap

    - by moonlightcheese
    I'm getting this error during compilation: Error occurred during initialization of VM Could not create the Java virtual machine. Could not reserve enough space for object heap What's worse, the error occurs intermittently. Sometimes it happens, sometimes it doesn't. It seems to be dependent on the amount of code in the application. If I get rid of some variables or drop some imported libraries, it will compile. Then when I add more to it, I get the error again. I've included the following sources into the application in the [project_root]/src/ directory: org.apache.httpclient (I've stripped all references to log4j from the sources, so don't need it) org.apache.codec (as a dependency) org.apache.httpcore (dependency of httpclient) and my own activity code consisting of nothing more than an instance of HttpClient. I know this has something to do with the amount of memory necessary during compile time or some compiler options, and I'm not really stressing my system while i'm coding. I've got 2GB of memory on this Core Duo laptop and windows reports only 860MB page file usage (haven't used any other memory tools. I should have plenty of memory and processing power for this... and I'm only compiling some common http libs... total of 406 source files. What gives? Android API Level: 5 Android SDK rel 5 JDK version: 1.6.0_12

    Read the article

  • Why am I getting 'Heap Corruption'?

    - by fneep
    Please don't crucify me for this one. I decided it might be good to use a char* because the string I intended to build was of a known size. I am also aware that if timeinfo-tm_hour returns something other than 2 digits, things are going to go badly wrong. That said, when this function returns VIsual Studio goes ape at me about HEAP CORRUPTION. What's going wrong? (Also, should I just use a stringbuilder?) void cLogger::_writelogmessage(std::string Message) { time_t rawtime; struct tm* timeinfo = 0; time(&rawtime); timeinfo = localtime(&rawtime); char* MessageBuffer = new char[Message.length()+11]; char* msgptr = MessageBuffer; _itoa(timeinfo->tm_hour, msgptr, 10); msgptr+=2; strcpy(msgptr, "::"); msgptr+=2; _itoa(timeinfo->tm_min, msgptr, 10); msgptr+=2; strcpy(msgptr, "::"); msgptr+=2; _itoa(timeinfo->tm_sec, msgptr, 10); msgptr+=2; strcpy(msgptr, " "); msgptr+=1; strcpy(msgptr, Message.c_str()); _file << MessageBuffer; delete[] MessageBuffer; }

    Read the article

  • Using StringBuilder to process csv files to save heap space

    - by portoalet
    I am reading a csv file that has about has about 50,000 lines and 1.1MiB in size (and can grow larger). In Code1, I use String to process the csv, while in Code2 I use StringBuilder (only one thread executes the code, so no concurrency issues) Using StringBuilder makes the code a little bit harder to read that using normal String class. Am I prematurely optimizing things with StringBuilder in Code2 to save a bit of heap space and memory? Code1 fr = new FileReader(file); BufferedReader reader = new BufferedReader(fr); String line = reader.readLine(); while ( line != null ) { int separator = line.indexOf(','); String symbol = line.substring(0, seperator); int begin = separator; separator = line.indexOf(',', begin+1); String price = line.substring(begin+1, seperator); // Publish this update publisher.publishQuote(symbol, price); // Read the next line of fake update data line = reader.readLine(); } Code2 fr = new FileReader(file); StringBuilder stringBuilder = new StringBuilder(reader.readLine()); while( stringBuilder.toString() != null ) { int separator = stringBuilder.toString().indexOf(','); String symbol = stringBuilder.toString().substring(0, separator); int begin = separator; separator = stringBuilder.toString().indexOf(',', begin+1); String price = stringBuilder.toString().substring(begin+1, separator); publisher.publishQuote(symbol, price); stringBuilder.replace(0, stringBuilder.length(), reader.readLine()); }

    Read the article

  • java heap allocation

    - by gurupriyan.e
    I tried to increase the heap size like the below C:\Data\Guru\Code\Got\adminservice\adminservice>java -Xms512m -Xmx512m Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -client to select the "client" VM -server to select the "server" VM -hotspot is a synonym for the "client" VM [deprecated] The default VM is client. -cp <class search path of directories and zip/jar files> -classpath <class search path of directories and zip/jar files> A ; separated list of directories, JAR archives, and ZIP archives to search for class files. -D<name>=<value> set a system property -verbose[:class|gc|jni] enable verbose output -version print product version and exit -version:<value> require the specified version to run -showversion print product version and continue -jre-restrict-search | -jre-no-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:<libname>[=<options>] load native agent library <libname>, e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:<pathname>[=<options>] load native agent library by full pathname -javaagent:<jarpath>[=<options>] load Java programming language agent, see java.lang.instrument It gave the help message as above - Does it mean that it was allocated?

    Read the article

  • heap sort function explanation needed

    - by Codeguru
    Hello, Can someone clearly explain me how these functions of heap sort are working?? void heapSort(int numbers[], int array_size) { int i, temp; for (i = (array_size / 2)-1; i >= 0; i--) siftDown(numbers, i, array_size); for (i = array_size-1; i >= 1; i--) { temp = numbers[0]; numbers[0] = numbers[i]; numbers[i] = temp; siftDown(numbers, 0, i-1); } } void siftDown(int numbers[], int root, int bottom) { int done, maxChild, temp; done = 0; while ((root*2 <= bottom) && (!done)) { if (root*2 == bottom) maxChild = root * 2; else if (numbers[root * 2] > numbers[root * 2 + 1]) maxChild = root * 2; else maxChild = root * 2 + 1; if (numbers[root] < numbers[maxChild]) { temp = numbers[root]; numbers[root] = numbers[maxChild]; numbers[maxChild] = temp; root = maxChild; } else done = 1; } }

    Read the article

  • Avoiding Heap Contention Among Threads

    Allocating memory from the system heap can be an expensive operation due to a lock used by system runtime libraries to synchronize access to the heap. Contention on this lock can limit the performance benefits from multithreading. Learn how to solve this problem.

    Read the article

  • Avoiding Heap Contention Among Threads

    Allocating memory from the system heap can be an expensive operation due to a lock used by system runtime libraries to synchronize access to the heap. Contention on this lock can limit the performance benefits from multithreading. Learn how to solve this problem.

    Read the article

  • ConcurrentLinkedQueue$Node remains in heap after remove()

    - by action8
    I have a multithreaded app writing and reading a ConcurrentLinkedQueue, which is conceptually used to back entries in a list/table. I originally used a ConcurrentHashMap for this, which worked well. A new requirement required tracking the order entries came in, so they could be removed in oldest first order, depending on some conditions. ConcurrentLinkedQueue appeared to be a good choice, and functionally it works well. A configurable amount of entries are held in memory, and when a new entry is offered when the limit is reached, the queue is searched in oldest-first order for one that can be removed. Certain entries are not to be removed by the system and wait for client interaction. What appears to be happening is I have an entry at the front of the queue that occurred, say 100K entries ago. The queue appears to have the limited number of configured entries (size() == 100), but when profiling, I found that there were ~100K ConcurrentLinkedQueue$Node objects in memory. This appears to be by design, just glancing at the source for ConcurrentLinkedQueue, a remove merely removes the reference to the object being stored but leaves the linked list in place for iteration. Finally my question: Is there a "better" lazy way to handle a collection of this nature? I love the speed of the ConcurrentLinkedQueue, I just cant afford the unbounded leak that appears to be possible in this case. If not, it seems like I'd have to create a second structure to track order and may have the same issues, plus a synchronization concern.

    Read the article

  • Java heap size - will this work?

    - by UnCon
    Hi, I try this with NetBeans desktop application template - increasing heapsize (to 512 MiB) of executed .jar file. (I believe that NetBeans uses Singleton app by default - SingleFrameView) Will it work? public static void main(String[] args) { if (args == null) { args = new String[1]; args[0] = "Xmx512m"; } else { String[] tempArgs = new String[args.length+1]; for (int i=0; i<args.length; i++) { tempArgs[i] = args[i]; } tempArgs[tempArgs.length-1] = "Xmx512m"; args = tempArgs; } launch(MyApp.class, args); } }

    Read the article

  • Heap Behavior in C++

    - by wowus
    Is there anything wrong with the optimization of overloading the global operator new to round up all allocations to the next power of two? Theoretically, this would lower fragmentation at the cost of higher worst-case memory consumption, but does the OS already have redundant behavior with this technique, or does it do its best to conserve memory? Basically, given that memory usage isn't as much of an issue as performance, should I do this?

    Read the article

  • Force an object to be allocated on the heap

    - by Warren Seine
    A C++ class I'm writing uses shared_from_this() to return a valid boost::shared_ptr<>. Besides, I don't want to manage memory for this kind of object. At the moment, I'm not restricting the way the user allocates the object, which causes an error if shared_from_this() is called on a stack-allocated object. I'd like to force the object to be allocated with new and managed by a smart pointer, no matter how the user declares it. I thought it could be done through a proxy or an overloaded new operator, but I can't find a proper way of doing that. Is there a common design pattern for such usage? If it's not possible, how can I test it at compile time?

    Read the article

  • Thread safety with heap-allocated memory

    - by incrediman
    I was reading this: http://en.wikipedia.org/wiki/Thread_safety Is the following function thread-safe? void foo(int y){ int * x = new int[50]; /*...do some stuff with the allocated memory...*/ delete x; } In the article it says that to be thread-safe you can only use variables from the stack. Really? Why? Wouldn't subsequent calls of the above function allocate memory elsewhere?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >