memory-management

Could not allocate enough heap space to Java

半腔热情 提交于 2020-01-21 05:17:40
问题 We have an application which was running fine for one year. It is a web application, running under Tomcat 5.5 + JDK 1.5 under Microsoft Cluster on Windows Server 2003 Enterprise Edition Service Pack 2. The server has 11Gb of RAM (I know that it is useless!) with the following description "Physical Address Extension": I don't know what that means. The Tomcat service is configured with the following parameters: -Xmx1024m -Xms128m Since last week, the service doesn't want to start anymore and

Could not allocate enough heap space to Java

独自空忆成欢 提交于 2020-01-21 05:17:12
问题 We have an application which was running fine for one year. It is a web application, running under Tomcat 5.5 + JDK 1.5 under Microsoft Cluster on Windows Server 2003 Enterprise Edition Service Pack 2. The server has 11Gb of RAM (I know that it is useless!) with the following description "Physical Address Extension": I don't know what that means. The Tomcat service is configured with the following parameters: -Xmx1024m -Xms128m Since last week, the service doesn't want to start anymore and

where does a “static final” directly allocated into? young gen or old gen or perm gen?

99封情书 提交于 2020-01-21 03:45:06
问题 Is a "static final" directly allocated into young gen or old gen or perm gen? (I guess it will most likely land into old gen over the time I suppose.) If it is allocated in the perm gen then, will it be garbage collected when class unloading takes place in Perm Gen ? 回答1: Is a "static final" directly allocated into young gen or old gen or perm gen? An object referenced by a static final variable will be allocated according to the same rules as any other object. It is most likely to be

Delete calling destructor but not deleting object?

ε祈祈猫儿з 提交于 2020-01-20 05:30:45
问题 So I have been working with c++ and pointers for a year and a half now, and i thought i had them succeed. I have called delete on objects many times before and the objects actually got deleted, or at least i thought they did. The code below is just confusing the hell out of me: #include <iostream> class MyClass { public: int a; MyClass() : a(10) { std::cout << "constructor ran\n"; } void method(std::string input_) { std::cout << param_ << "\n"; } ~MyClass() { std::cout << "destructor ran\n";

How might I overload the “new” operator to allocate memory from a secondary memory device?

我与影子孤独终老i 提交于 2020-01-20 04:22:27
问题 I am looking for a syntax to allocate memory from a secondary memory device and not from the default heap. How can i implement it? Using malloc() would by default take it from heap... Surely there must be another way! 回答1: #include <new> void* operator new(std::size_t size) throw(std::bad_alloc) { while (true) { void* result = allocate_from_some_other_source(size); if (result) return result; std::new_handler nh = std::set_new_handler(0); std::set_new_handler(nh); // put it back // this is

Method Area and PermGen

旧街凉风 提交于 2020-01-19 23:07:07
问题 I was trying to understand the memory structure of HotSpot JVM and got confused with the two terms "Method Area" and "PermGen" space. The docs I referred to say that Method Area contains the definition of classes and methods including the byte code. Some other docs say that they are stored in the PermGen space. So can I conclude that these two memory areas are same ? 回答1: You should take a look at Java Memory Types and optionally at this doc about the Garbage Collection in Java. The latter is

How can I create a reference cycle using dispatchQueues?

本秂侑毒 提交于 2020-01-19 06:09:06
问题 I feel that I've always misunderstood that when reference cycles are created. Before I use to think that almost any where that you have a block and the compiler is forcing you to write .self then it's a sign that I'm creating a reference cycle and I need to use [weak self] in . But the following setup doesn't create a reference cycle. import Foundation import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution class UsingQueue { var property : Int = 5 var queue : DispatchQueue?

Trick behind JVM's compressed Oops

空扰寡人 提交于 2020-01-19 03:19:39
问题 So I understand the compressed oops is enabled by default in HotSpot VM now. It has support for this from Java SE 6u23 onwards through the VM option -XX:+UseCompressedOops . I understand that it allows for efficient CPU cache utilization as the CPU caches can hold a larger number of references than if they had to deal with 64 bit sized references. But what I do not understand is how using only 32 bits JVM can address up to 2 64 addresses. To simplify the problem how can we address up to 2 4

Custom data size for memory alignment

ⅰ亾dé卋堺 提交于 2020-01-17 12:39:09
问题 Each datatype has a certain range, based on the hardware. For example, on a 32bit machine an int has the range -2147483648 to 2147483647. C++ compilers 'pad' object memory to fit into certain sizes. I'm pretty sure it's 2, 4, 8, 16, 32, 64 etc. This also probably depends on the machine. I want to manually align my objects to meet padding requirements. Is there a way to: Determine what machine a program is running on Determine padding sizes Set custom data-type based on bitsize I've used

C: Not explicitly returning constructed struct, but it still works

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-17 08:21:43
问题 I write a 'constructor' function that makes a Node in C, compiled with Visual Studio 2008, ANSI C mode. #include <stdio.h> #include <stdlib.h> typedef struct _node { struct _node* next ; char* data ; } Node ; Node * makeNode() { Node * newNode = (Node*)malloc( sizeof(Node) ) ; // uncommenting this causes the program to fail. //puts( "I DIDN'T RETURN ANYTHING!!" ) ; } int main() { Node * myNode = makeNode() ; myNode->data = "Hello there" ; // elaborate program, still works puts( myNode->data )