stack

Is it on the Stack or Heap?

邮差的信 提交于 2020-01-13 02:46:07
问题 I have some C code that is something of a puzzle. For a reason to do with this code, I'm wondering how I can tell if a struct object is ending up on the heap or stack? The objects are not being created with malloc or calloc . They start their life in the form of an array. For the purposes of this post, I'm going to call the struct Emp. Emp myEmp[6]; /* Each myEmp[?] item is populated in code */ The objects are sorted and manipulated in various ways and at some point, the objects are copied

Computing method call stack size for checking StackOverflowException

北城以北 提交于 2020-01-12 14:07:08
问题 Today morning I answered a question which is related to StackoverflowException . The person has asked when Stackoverflow exception occurs See this link Simplest ways to cause stack overflow in C#, C++ and Java So my question is that is there any method by which we can compute the method call stacks size dynamically in our program and then applying a check before calling a method which checks whether method call stack has space to accommodate it or not to prevent StackOverflowException. As I

Pushing variables to Stack and Variables living in the Stack difference?

China☆狼群 提交于 2020-01-12 04:28:05
问题 So I know that there exists 2 memory areas: Stack and Heap . I also know that if you create a local variable it will live in the Stack, not in the heap. Stack will grow as we push data into it as in: Now I will try to pass the confusion I am having to you: For example this simple Java Code: public class TestClass { public static void main(String[] args) { Object foo = null; Object bar = null; } } is translated into this byte code: public static void main(java.lang.String[]); Code: Stack=1,

How do I avoid onCreate() being called when starting an Activity?

橙三吉。 提交于 2020-01-11 05:48:05
问题 I want to reload an activity from stack. I use startActivity() to start new activities. When I'm on Activity D I want to reload Activity A and not start a new Intent. I can't use startActivity() when calling A from D because it will fire onCreate() which starts a thread to fetch some data. EDIT : Updated the stack. If I use FLAG_ACTIVITY_REORDER_TO_FRONT it calls the onCreate() method again. Following is my scenario. Login Activity ̣→ Activity A → Activity B → Activity C → Activity D →

Value types in object stored in heap as well?

狂风中的少年 提交于 2020-01-11 05:12:05
问题 I can imagine this question has been asked thousands of times, but I didn't have much luck in finding the answer, plus this is more out of curiosity than need. Digging into the nuts and bolts of C#, I was wondering since objects are stored in the heap, are the value types within the objects stored in the heap as well or are they placed in the stack? 回答1: They are stored in the heap, inside of the memory allocated for the reference type. In addition, value types are often stored in places

cargo test --release causes a stack overflow. Why doesn't cargo bench?

浪尽此生 提交于 2020-01-11 04:50:06
问题 In trying to write an optimized DSP algorithm, I was wondering about relative speed between stack allocation and heap allocation, and size limits of stack-allocated arrays. I realize there is a stack frame size limit, but I don't understand why the following runs, generating seemingly realistic benchmark results with cargo bench , but fails with a stack overflow when run with cargo test --release . #![feature(test)] extern crate test; #[cfg(test)] mod tests { use test::Bencher; #[bench] fn it

Can Java allocate a list on stack?

陌路散爱 提交于 2020-01-11 00:46:26
问题 Every time when I initiate a list in java, I will do List<Integer> list = new LinkedList<>(); I assume that this will allocate the list on heap. Wonder if there's anyway that I could allocate the list on stack? 回答1: All objects, including their individual attributes, are stored on the heap. All local variables, and their arguments, are stored on the stack because they contain primitive values or references. However, in special cases, the java virtual machine may perform escape analysis and

gcc gnu assembly kernel in real mode

我怕爱的太早我们不能终老 提交于 2020-01-07 06:47:20
问题 i am trying to build a 16bit kernel in gcc gnu assembly while my bootloader is written in pure assembly but i have trouble printing out strings while single character are okay: Here is my bootloader.asm: org 0x7c00 bits 16 section .text mov ax,0x1000 mov ss,ax mov sp,0x000 mov esp,0xfffe xor ax,ax mov es,ax mov ds,ax mov [bootdrive],dl mov bh,0 mov bp,zeichen mov ah,13h mov bl,06h mov al,1 mov cx,6 mov dh,010h mov dl,01h int 10h load: mov dl,[bootdrive] xor ah,ah int 13h jc load load2: mov ax

UPnP: intel: generate stack: java android: invoking actions on network light sample

↘锁芯ラ 提交于 2020-01-06 15:14:46
问题 I`m looking into UPnP with the help of the generated stack for java/android created with the device builder with came with the UPnP tools from intel. to make an android application that is the control point in the UPnP system. source of tools: http://opentools.homeip.net/dev-tools-for-upnp To help me understand the principle of these tools I created a network light and generated the stack for android. But i can`t seem to work out how to turn on and off the networklight. can someone give my a

Singleton class for moving heap to stack

江枫思渺然 提交于 2020-01-06 14:16:17
问题 I have written some class that moves heap allocated stuff to stack (hopefully :) ). This calss is singleton because only this class should be responsible for holding and managing part of stack. My question is: Is my code correct? Code is correct in the sense of programming (no compile errors, no memory errors and leaks (checked by valgrind)). But does the code really moves heap to stack? Here's the code: stack.hpp: class CStack{ public: void* getAlloc(long); static CStack* Instance(); private