heap

heapq python - how to modify values for which heap is sorted

爷,独闯天下 提交于 2019-12-23 03:18:22
问题 I transform an empty list called UNVISITED into a heap, such that: UNVISITED = [] heapq.heappush(UNVISITED, (a.f, a)) The object a that I push, which is instantiated from a class, has the following fields: class UNVISITEDNode(): def __init__(self, value1, value2 , value3, value4, value5): self.q = value1 self.h = value2 self.g = value3 self.f = value4 self.p = value5 Throughout my algorithm, I keep modifying any valueX from the object already in the heap whenever is needed like: for i in

JVM HeapDump: The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Segment

醉酒当歌 提交于 2019-12-23 02:17:01
问题 I have trouble with the JVM-Heap. We operate a website with Apache HTTP Server and an Apache Tomcat Application Server. All *.jsp Requests to the Apache HTTP Server will be redirected to the Tomcat Server (protocol: ajp). The website has more than 10'000 jsp files. We have also a google search appliance and it crawle the website every night. While it crawling, the jvm heap space rise to the max limit of 8 GB. With javamelody, I can see that the heap space increase analogue to the loaded

How increasing swap size allow me to increase the heap size?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 01:45:23
问题 I have ubuntu server where i have 8 GB of RAM. When i try to give the heap size as 8GB, my web server(weblogic) does not start. But if i increase the swap size to Size to 11 GB, webserver got started. So my question is how i can allocate 8GB heap size to my web server (when ihave 8 GB RAM out of which 1 to 2 GB is required for OS) after increaing the swap size ? 回答1: Do. Not. Do this. Get more memory. Java and Swap Do. Not. Mix. Java and Swap are like "Crossing the Streams" Bad. Part of the

Direct stack and heap access; Virtual- or hardware- level?

一个人想着一个人 提交于 2019-12-22 14:58:42
问题 When I'm on SO I read a lot of comments guiding (Especially in C) "dynamic allocation allways goes to the heap, automatic allocation on the stack" But especially regarding to plain C I disaggree with that. As the ISO/IEC9899 doesn't even drop a word of heap or stack. It just mentions three storage duriations (static, automatic, and allocated) and advises how each of them has to be treat. What would give a compiler the option to do it even wise versa if it would like to. So my question is: Are

Finding the smallest element of a binary max heap stored as Ahnentafel array

别说谁变了你拦得住时间么 提交于 2019-12-22 13:06:44
问题 I have a binary max heap (largest element at the top), and I need to keep it of constant size (say 20 elements) by getting rid of the smallest element each time I get to 20 elements. The binary heap is stored in an array, with children of node i at 2*i and 2*i+1 (i is zero based). At any point, the heap has 'n_elements' elements, between 0 and 20. For example, the array [16,14,10,8,7,9,3,2,4] would be a valid max binary heap, with 16 having children 14 and 10, 14 having children 8 and 7 ...

unexpected output of size allocated by malloc in C [closed]

断了今生、忘了曾经 提交于 2019-12-22 12:53:34
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I have read that malloc actually allocates (required_size + 1) blocks of memory and it stores the size in the first block and the pointer to the second

Heap corruption when deleting a string

只愿长相守 提交于 2019-12-22 11:22:49
问题 Here is my code: std::string readString() { int strLen = Read<int>(); char* rawString = new char[strLen]; Read(rawString, strLen); rawString[strLen] = '\0'; std::string retVal(rawString); delete [] rawString; return retVal; } The first line reads the length of the string. The second line creates a new char array (c-string) with the string length The third line reads the string (its reading it from a file) The 4th line adds a NULL to the end. The 5th line creates an std::string out of the c

Heap corruption when deleting a string

左心房为你撑大大i 提交于 2019-12-22 11:20:27
问题 Here is my code: std::string readString() { int strLen = Read<int>(); char* rawString = new char[strLen]; Read(rawString, strLen); rawString[strLen] = '\0'; std::string retVal(rawString); delete [] rawString; return retVal; } The first line reads the length of the string. The second line creates a new char array (c-string) with the string length The third line reads the string (its reading it from a file) The 4th line adds a NULL to the end. The 5th line creates an std::string out of the c

Is heap an abstract data type? If so, what about priority queues?

て烟熏妆下的殇ゞ 提交于 2019-12-22 10:53:54
问题 I read that priority queue is an abstract data type for heap data structure or to put it in another way, heap is an implementation for priority queues. But what confuses me is that I see heap in itself as an ADT since they're normally implemented using arrays (talking about min/max heaps here). Could someone give me a clear distinction among the three within the realm of ADT? 回答1: Let me answer you in two steps.. i) Defenitions Data type is a set of values together with operations on that

How to Increase heap size in Java ME?

天涯浪子 提交于 2019-12-22 10:48:25
问题 Is there any way to increase the heap size for Java ME on a device? I'm developing an application for a Nokia N95, but am bumping into memory issues when I try to do image processing of larger images. The phone has plenty of heap space available, but seems to restrict the amount allowed to be used by Java ME to 1MB. 回答1: Short answer: No. Longer answer: Heap-size is hardcoded in device VM. If you are running out of memory you need to split you task into more smaller sub tasks to allow GC to