heap

How to print the location of Heap using java for a process?

回眸只為那壹抹淺笑 提交于 2020-01-06 08:24:15
问题 I want to test if ASLR which randomizes the location of a heap for a process actually works. 回答1: You can't do this in pure Java. Machine address (pointers) are not exposed to Java applications. Even if they did, there's no Java API that tells you were the heap is. I suppose that you could use the values returned by System.identityHashcode() as ersatz machine addresses. If you wrote a simple Java test application that examined identity hashcode of a sample object, then ran it multiple times

Set Java / Tomcat heap size (Xmx) without modifying catalina.sh

送分小仙女□ 提交于 2020-01-06 06:56:55
问题 Most people seem to suggest setting the Java/Tomcat heap memory size for Tomcat6 by editing the /usr/share/tomcat6/bin/catalina.sh file, and adding something like: # Set specific memory requirements for Tomcat6 (for server with ~512MB RAM). CATALINA_OPTS="$CATALINA_OPTS -server -Xms128m -Xmx256m" I am trying to build an Ansible playbook to configure a Tomcat-based server on Ubuntu, and it doesn't seem to me like having an entire custom catalina.sh file would be ideal—is there some other

Secondary Order in Heap::Simple

喜夏-厌秋 提交于 2020-01-06 06:02:30
问题 How do I define a secondary ordering to the Heap::Simple interface in Perl? 回答1: The documentation states that the constructor takes a code reference to define the order, so you can specify any sort method you like: my $heap = Heap::Simple->new(order => \&sort_method); Every time two keys need to be compared, the given code reference will be called like: $less = $code_reference->($key1, $key2); This should return a true value if $key1 is smaller than $key2 and a false value otherwise. $code

Scheme Inserting Pairs into Heap

孤人 提交于 2020-01-06 05:51:57
问题 This is part of a homework assignment that I can't seem to figure out. I was wondering if someone could point me in the right direction? The problem reads: (insert-list-of-pairs vw-pair-list heap) evaluates to the heap resulting from inserting all of the value - weight pairs from the list vw-pair-list into the heap heap . The following functions were created earlier in the homework for use in this problem: (define (create-heap vw-pair left right) (list vw-pair left right)) (define (h-min heap

How to increase Tomcat Heap memory on windows

£可爱£侵袭症+ 提交于 2020-01-06 04:37:08
问题 I read many posts on the internet and here on stackoverflow, but I'm still not able to increase Tomcat Heap Siz e. Probably I made an error that I can't recognize. Following this guide I did these steps: I created the file setenv.bat inside the folder {tomcat}\bin Inside the file setenv.bat I added the string set "JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx1024m -XX:MaxPermSize=512m -server" When I run Tomcat and then I launch my app (for instance localhost:8080/appName) and I try to know the heap

Java garbage collection problem

对着背影说爱祢 提交于 2020-01-06 04:26:27
问题 So I have this extremely memory-intensive Java application I'm building, which builds a tree of millions of nodes. Using the handy dandy Runtime methods for getting heap information, I built a nice little method that displays the current memory usage, as shown below: public void displayMemoryUsage() { long maxMem = Runtime.getRuntime().maxMemory(); long freeMem = Runtime.getRuntime().freeMemory(); long heapMem = Runtime.getRuntime().totalMemory(); long usedMem = heapMem - freeMem; System.out

C++ When to allocate on heap vs stack?

こ雲淡風輕ζ 提交于 2020-01-06 02:29:06
问题 Whilst asking another question (and also before) I was wondering how do I judge whether to create an object on the heap or keep it as an object on the stack? What should I ask myself about the object to make the correct allocation? 回答1: Put it on the heap if you have to, the stack if you can. What kinds of things do you need to put on the heap? Anything of varying length. Any object that might need to be null. Anything that's very large, lest you cause a stack overflow. 回答2: Simple answer.

JVM fails to allocate XMS under Suse SLES10 X64 running on VMWare ESX

不羁的心 提交于 2020-01-06 02:20:16
问题 I am trying to allocate ram with xms = xmx on a sles10 x64 running under VMware. When stopping the JVM the following error is thrown: Java HotSpot(TM) 64-Bit Server VM warning: Failed to reserve shared memory (errno = 12). The RAM of the VM is 8 GB and they are reserved. The VM sees 8GB and it can be allocated during runtime via the XMX setting. On another Virtual SLES10 with 16 GB RAM Reserved via VMWare I don't have a problem with allocation of RAM even when setting the hugepages and shmax

scope of struct pointers in functions

不问归期 提交于 2020-01-05 19:12:21
问题 If i have the following in a function: struct example *A=malloc(sizeof(struct example)); does the node/memory space created where A points to get destroyed after the function ends/leaves? Or does it stay in the heap? 回答1: No. memory allocated by malloc will stay allocated until free 'd. Doing things like this: char * function(void) { char c = 'a'; return &c; } on the other hand, is bad, because this object DOES go out of scope when the function ends. malloc allocates memory on the heap.

scope of struct pointers in functions

梦想与她 提交于 2020-01-05 19:12:03
问题 If i have the following in a function: struct example *A=malloc(sizeof(struct example)); does the node/memory space created where A points to get destroyed after the function ends/leaves? Or does it stay in the heap? 回答1: No. memory allocated by malloc will stay allocated until free 'd. Doing things like this: char * function(void) { char c = 'a'; return &c; } on the other hand, is bad, because this object DOES go out of scope when the function ends. malloc allocates memory on the heap.