stack

Cassandra:The stack size specified is too small, Specify at least 228k

廉价感情. 提交于 2020-01-01 07:41:11
问题 I'm getting this error when starting cassandra after upgrade. Any idea? # cassandra -f xss = -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1920M -Xmx1920M -Xmn200M -XX:+HeapDumpOnOutOfMemoryError -Xss180k The stack size specified is too small, Specify at least 228k Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 回答1: I have fixed it by editing file /etc/cassandra

Overflowed buffer data does not get stored contiguously

青春壹個敷衍的年華 提交于 2020-01-01 07:03:46
问题 I have the following code to simulate buffer overflow. Edit: I missed an important step in the code below. As the discussion progressed that the variable c is getting modified. void function (int fd, int e) { int i = 0; int n; char c; char s[44]; . . c = getchar(fd); . //Some check on c s[i++] = c; . //Some more local variables and some operations on them. } I am trying to overflow the buffer by sending more input > 4 bytes in order to see how the local variables and EBP and RET and arguments

C++ stack and scope

倖福魔咒の 提交于 2020-01-01 04:52:06
问题 I tried this code on Visual C++ 2008 and it shows that A and B don't have the same address. int main() { { int A; printf("%p\n", &A); } int B; printf("%p\n", &B); } But since A doesn't exist anymore when B gets defined, it seems to me that the same stack location could be reused... I don't understand why the compiler doesn't seem to do what looks like a very simple optimization (which could matter in the context of larger variables and recursive functions for example). And it doesn't seem

Is there any hard-wired limit on recursion depth in C

谁说胖子不能爱 提交于 2020-01-01 04:17:47
问题 The program under discussion attempts to compute sum-of-first-n-natural-numbers using recursion . I know this can be done using a simple formula n*(n+1)/2 but the idea here is to use recursion . The program is as follows: #include <stdio.h> unsigned long int add(unsigned long int n) { return (n == 0) ? 0 : n + add(n-1); } int main() { printf("result : %lu \n", add(1000000)); return 0; } The program worked well for n = 100,000 but when the value of n was increased to 1,000,000 it resulted in a

new on stack instead of heap (like alloca vs malloc)

僤鯓⒐⒋嵵緔 提交于 2019-12-31 09:44:07
问题 Is there a way to use the new keyword to allocate on the stack (ala alloca ) instead of heap ( malloc ) ? I know I could hack up my own but I'd rather not. 回答1: To allocate on the stack, either declare your object as a local variable by value , or you can actually use alloca to obtain a pointer and then use the in-place new operator: void *p = alloca(sizeof(Whatever)); new (p) Whatever(constructorArguments); However, while using alloca and in-place new ensures that the memory is freed on

new on stack instead of heap (like alloca vs malloc)

。_饼干妹妹 提交于 2019-12-31 09:44:00
问题 Is there a way to use the new keyword to allocate on the stack (ala alloca ) instead of heap ( malloc ) ? I know I could hack up my own but I'd rather not. 回答1: To allocate on the stack, either declare your object as a local variable by value , or you can actually use alloca to obtain a pointer and then use the in-place new operator: void *p = alloca(sizeof(Whatever)); new (p) Whatever(constructorArguments); However, while using alloca and in-place new ensures that the memory is freed on

c# structs/classes stack/heap control?

元气小坏坏 提交于 2019-12-31 09:04:51
问题 so in c++ it's very easy. you want whatever class/struct to be allocated on the heap, use new. if you want it on the stack, don't use new. in C# we always use the new keyword, and depending on whether it's a struct or a class it's allocated either on the stack or on the heap (structs go to the stack, classes to the heap) - and in some applications there can be a HUGE performance difference when changing the design such that only those objects go to the heap that really belong there. What I

c# structs/classes stack/heap control?

依然范特西╮ 提交于 2019-12-31 09:04:31
问题 so in c++ it's very easy. you want whatever class/struct to be allocated on the heap, use new. if you want it on the stack, don't use new. in C# we always use the new keyword, and depending on whether it's a struct or a class it's allocated either on the stack or on the heap (structs go to the stack, classes to the heap) - and in some applications there can be a HUGE performance difference when changing the design such that only those objects go to the heap that really belong there. What I

How to allocate arrays on the stack for performance gains?

廉价感情. 提交于 2019-12-31 07:45:06
问题 Some of the most optimal versions of functions like popcount and count consecutive zeros use table lookups to get the final answer. In C and C++ one can allocate arrays on the stack and access them quickly. Is there a way to do this in C# as well? As far as I know, stackalloc can only be used within functions and thus the array won't persist. I have a small lookup table that I'd like to be able to access as quickly as possible and thus would prefer to allocate it on the stack rather than heap

Does pushing a register empty that register?

北城以北 提交于 2019-12-31 05:41:34
问题 I have read many books and instructions on this, but one thing that is never specified is what happens to a register after you push it on the stack. For example if you write in assembly "push ECX", the contents of the ECX register will be pushed on the stack (obviously). What I don't know is, once you did this, does the ECX register keep the value it contained before the push, or did it empty itself after the push? 回答1: CPUs almost always copy , not copy + zero-the-src . Despite instruction