heap

with expression vs new keyword

倖福魔咒の 提交于 2020-06-29 06:45:27
问题 I was reading the devblogs about "what's new in C#9.0", then I noticed "with expression". public data class Person { public string FirstName { get; init; } public string LastName { get; init; } } var otherPerson = person with { LastName = "Hanselman" }; they say A record implicitly defines a protected “copy constructor” – a constructor that takes an existing record object and copies it field by field to the new one: protected Person(Person original) { /* copy all the fields */ } // generated

with expression vs new keyword

一个人想着一个人 提交于 2020-06-29 06:45:18
问题 I was reading the devblogs about "what's new in C#9.0", then I noticed "with expression". public data class Person { public string FirstName { get; init; } public string LastName { get; init; } } var otherPerson = person with { LastName = "Hanselman" }; they say A record implicitly defines a protected “copy constructor” – a constructor that takes an existing record object and copies it field by field to the new one: protected Person(Person original) { /* copy all the fields */ } // generated

array wrapper corrupts stack

有些话、适合烂在心里 提交于 2020-06-29 03:48:31
问题 my project is a dynamic array wrapper like std::vector. this is how it works: when adding a new element, the memory is either allocated (malloc), if it is 0, or reallocated with a new size (realloc), if it is not 0. the size is the number of elements * size of type when getting an already added element, i calculate the address by multiplying its index by the size of the type and adding it to the address at which the memory is allocated NOTE: i write and read the memory myself with no function

GCC: How to disable heap usage entirely on an MCU?

早过忘川 提交于 2020-06-24 22:42:24
问题 I have an application that runs on an ARM Cortex-M based MCU and is written in C and C++. I use gcc and g++ to compile it and would like to completely disable any heap usage. In the MCU startup file the heap size is already set to 0. In addition to that, I would also like to disallow any accidental heap use in the code. In other words, I would like the linker (and/or the compiler) to give me an error when the malloc , calloc , free functions or the new , new[] , delete , delete[] operators

Java- Where does the variable name or Identifier gets stored, Stack or Heap?

南笙酒味 提交于 2020-06-22 12:46:07
问题 Where does the identifiers or variable name gets stored in java? I understand that objects get stored in heap and variable gets store in heap or stack depending on the type and scope of variable. Can we debug or write any program to confirm it? Thanks & Regards 回答1: Names of fields are stored as part of the class metadata, in formerly-PermGen now-Metaspace. Array elements don't have names, only numbers. (Cue Patrick McGoohan.) Names of method and constructor parameters and local variables and

Priority Queue with a find function - Fastest Implementation

断了今生、忘了曾经 提交于 2020-06-09 17:00:09
问题 I am looking at implementing a priority queue with an added requirement, a find/search function which will tell whether an item is anywhere within the queue. So the functions will be: insert, del-min and find. I am unsure whether I should use a Heap or a Self-balancing binary search tree. It appears PQs are usually implemented with a Heap, but I am wondering if there is any advantage in using a binary search tree since I also need that find function. Furthermore, on average I'll be doing more

Priority Queue with a find function - Fastest Implementation

无人久伴 提交于 2020-06-09 16:59:10
问题 I am looking at implementing a priority queue with an added requirement, a find/search function which will tell whether an item is anywhere within the queue. So the functions will be: insert, del-min and find. I am unsure whether I should use a Heap or a Self-balancing binary search tree. It appears PQs are usually implemented with a Heap, but I am wondering if there is any advantage in using a binary search tree since I also need that find function. Furthermore, on average I'll be doing more

Why does a pointer to a local variable escape to the heap?

半世苍凉 提交于 2020-05-10 04:18:08
问题 Here is my go environment: [lorneli@localhost GoTest]$ go version go version go1.9 linux/amd64 Here is my program: package main type request struct { ID string size uint32 off uint64 } func main() { r := request{} iter := interface{}(&r) // &r escapes to heap iters := make([]interface{}, 0) iters = append(iters, iter) } I allocate a request instance and convert the pointer of it to interface{} . But when analysing with flag -gcflags "-m" , I found out the instance escapes to heap when

增加堆内存的大小

若如初见. 提交于 2020-05-03 21:51:59
增加堆内存的大小 - 提防眼镜蛇效应 原文: http://plumbr.eu/blog/increasing-heap-size-beware-of-the-cobra-effect "眼镜蛇效应"起源于当时英国统治印度殖民地的轶事。英国政府关心一些有毒的眼镜蛇.所以政府对每条死蛇提供奖励.最初这个方案很成功为了奖励大量的毒蛇被杀死.然而最终印度人为了收入开始养殖眼镜蛇. 当意识到奖励取消了,养殖眼镜蛇和野生眼镜蛇成倍增加了. 明显的这个问题解决方案使这个情况更糟了. 如何调整Java堆内存的大小就像殖民地印度和毒蛇的关系.多包涵,我会引导你通过这个比喻用一个故事从现实生活中作为参考。 你已经创建了一个强大的程序. 如此强大使程序变的真正的流利和有巨大的流量,新的服务开始添加到你的程序中.通过挖掘你决定的性能指标,你程序的可用堆内存将不久成为瓶颈. 因此你部署了是原来6倍堆内存的基础设施. 你测试你的程序验证它可以工作.你部署它到新的硬件上.但是立即开始抱怨下面的问题 - 你的程序变的比以前2GB堆内存时响应要慢. 你的一些用户面临着分等待你的程序的响应延迟几分钟. 发生了什么? 可以有很多原因.不过,让我们关注最有可能发生的地方 - 堆内存大小的改变.这里有几种不好的效果像扩展缓存的预热时间,碎片问题等.但是从症状上来看你最有可能面临的是full GC期间的延迟问题.

Drools 6.3.0: Old ZiPKieModules remain in the heap after upgrading (executing scanNow in kiescanner JMX bean)

[亡魂溺海] 提交于 2020-04-30 08:11:53
问题 We are using drools 6.3.0 and implemented our kiemodule as a deployable maven artifact (kjar). Our application uses this kiemodule and runs in Wildfly-10. In production, newer version of the kiemodule are automatically detected and loaded in the application by a kieScanner that runs at regular intervals. If the scanner sees a new version of the kiemodule it will load it on-the-fly and at runtime. This is very cool functionality, but recently we discovered that every time a new ZipKieModule is