heap

Does this type of memory get allocated on the heap or the stack?

邮差的信 提交于 2019-12-17 07:53:44
问题 In the context of C++ (not that it matters): class Foo{ private: int x[100]; public: Foo(); } What I've learnt tells me that if you create an instance of Foo like so: Foo bar = new Foo(); Then the array x is allocated on the heap, but if you created an instance of Foo like so: Foo bar; Then it's created on the stack. I can't find resources online to confirm this. 回答1: Given a slight modification of your example: class Foo{ private: int x[100]; int *y; public: Foo() { y = new int[100]; } ~Foo(

Are there stackless or heapless implementation of C++?

筅森魡賤 提交于 2019-12-17 07:33:07
问题 C++ standard does not mention anything about the stack or the heap, they are implementation specific , which is true. Even though they are not part of the C++ standard, we end up using them anyway, so much that it's like they are part of the language itself and have to be taken into consideration for memory or performance purpose. Hence my question are there implementations of C++ that doesn't use stacks and heaps? 回答1: Others have already given good answers about the heap, so I'll leave that

Understanding max JVM heap size - 32bit vs 64bit

僤鯓⒐⒋嵵緔 提交于 2019-12-17 06:37:12
问题 I've read the max heap size on 32bit Windows is ~1.5GB which is due to the fact that the JVM requires contiguous memory. Can someone explain the concept of "contiguous memory" and why you only have max 1.5GB on Windows? Secondly, what then is the max heap size on 64 bit Windows and why is this different than what's available on 32 bit? 回答1: The 32-bit/64-bit part is unrelated to Java It turns out that memory locations in a 32-bit system are referenced by 32-bit unsigned integers. This allows

Increase JVM max heap size for Eclipse

梦想的初衷 提交于 2019-12-17 06:35:42
问题 I am trying to increase the max heap size for my Eclipse. I have tried specifying in eclipse.ini or through the command line, but are not working. My max heap size has the exact same limit before (running jconsole) and after ( System.out.println(java.lang.Runtime.getRuntime().maxMemory()); ) starting Eclipse. 1.8G Is there any way to modify JVM heap size before it is launched (ex. a config file?) What could I be doing wrong when specifying heap size to Eclipse? This is the command: ./eclipse

Linux Allocator Does Not Release Small Chunks of Memory

我的未来我决定 提交于 2019-12-17 05:04:46
问题 The Linux glibc allocator seems to be behaving weirdly. Hopefully, someone can shed some light on this. Here is the source file that I have: first.cpp: #include <unistd.h> #include <stdlib.h> #include <list> #include <vector> int main() { std::list<char*> ptrs; for(size_t i = 0; i < 50000; ++i) { ptrs.push_back( new char[1024] ); } for(size_t i = 0; i < 50000; ++i) { delete[] ptrs.back(); ptrs.pop_back(); } ptrs.clear(); sleep(100); return 0; } second.cpp: #include <unistd.h> #include <stdlib

Increase JVM heap size for Scala?

不羁的心 提交于 2019-12-17 04:16:55
问题 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 command line or from a Bash script using the "scala" runner. How do I increase the JVM heap size for this? I've tried passing -Xmx1024m , but it does not recognize this argument. I'm using a nightly

Can min/max of moving window achieve in O(N)?

橙三吉。 提交于 2019-12-17 03:19:02
问题 I have input array A A[0], A[1], ... , A[N-1] I want function Max(T,A) which return B represent max value on A over previous moving window of size T where B[i+T] = Max(A[i], A[i+T]) By using max heap to keep track of max value on current moving windows A[i] to A[i+T], this algorithm yields O(N log(T)) worst case. I would like to know is there any better algorithm? Maybe an O(N) algorithm 回答1: O(N) is possible using Deque data structure. It holds pairs (Value; Index). at every step: if (!Deque

Setting JVM heap size at runtime

妖精的绣舞 提交于 2019-12-17 03:07:19
问题 Is there a way to set heap size from a running Java program? 回答1: No. What you can do with an app that has very variable heap requirements is to set your max heap size very high with -Xmx and tune -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio so that the app will not hang on to a lot of memory when the heap shrinks (it does that with default settings). But note that this may cause performance problems when the memory actually used by the app varies both strongly and quickly - in that case you

Why are two different concepts both called “heap”?

无人久伴 提交于 2019-12-17 02:30:11
问题 Why are the runtime heap used for dynamic memory allocation in C-style languages and the data structure both called "the heap"? Is there some relation? 回答1: Donald Knuth says (The Art of Computer Programming, Third Ed., Vol. 1, p. 435): Several authors began about 1975 to call the pool of available memory a "heap." He doesn't say which authors and doesn't give references to any specific papers, but does say that the use of the term "heap" in relation to priority queues is the traditional

Evaluating expressions called from Java in R. Out of Memory Error: Java Heap

狂风中的少年 提交于 2019-12-14 04:22:06
问题 I have an issue loading a large dataset into R from Java. The problem is actually with the function I am using: re.eval() . I want to load a file into R so that I can analyse/manipulate it in R, however I want to do this from Java (this is in order to build a GUI). What I want the function to do is parse and evaluate the string I provide, however, the eval function parses, evaluates and returns the result. I get an out of memory error from java regarding the heap size. This is the code I have