stack

Difference between “call stack” and “thread stack”

蹲街弑〆低调 提交于 2019-12-03 07:28:09
问题 Is there a semantic difference between the terms call stack and thread stack , in Java multithreading? 回答1: Each thread has its own call stack, "call stack" and "thread stack" are the same thing. Calling it a "thread stack" just emphasizes that the call stack is specific to the thread. Bill Venners calls this the Java stack: When a new thread is launched, the Java virtual machine creates a new Java stack for the thread. As mentioned earlier, a Java stack stores a thread's state in discrete

How to debug Android ANR?

梦想与她 提交于 2019-12-03 07:26:49
问题 My Android app gets a lot of ANR reports lately in the Google Play console. Since this started to happen when I included Google Analytics in the app, I strongly suspect Analytics to cause it. Problem is that I know how to debug a crash using the stack trace. But I'm not sure about how to debug an ANR. I guess that an ANR means that the main thread is blocked somewhere. But how to know where it is blocked? See below one of the typical ANR I got lately. How to interpret it and start figuring

logical structure/details of a reference variable and object in the memory?

余生颓废 提交于 2019-12-03 07:10:38
Let's say we have a class: class Class1 { int i = 1; } and we have a variable: Class1 ob1 = new Class1(); Does a reference itself stored in a variable ob1 store the information that it refers to an object of Class1 ? Does the part of the heap where Class1 is stored store the information that it is of Class1 type? How does logically looks like this information? It's a string like application1.Class1 or a reference to some reference types pool? If you can recommend the source of such information I'll be very grateful for providing it I can't find it in the reference book. Does a reference itself

Copy std::stack into an std::vector

百般思念 提交于 2019-12-03 06:41:59
Is the following code guaranteed by the standard to work(assuming st is not empty)? #include <vector> #include <stack> int main() { extern std::stack<int, std::vector<int> > st; int* end = &st.top() + 1; int* begin = end - st.size(); std::vector<int> stack_contents(begin, end); } ronag Yes. std::stack is just a container adapter. You can see that .top() is actually (§23.3.5.3.1) reference top() { return c.back(); } Where c is the container, which in this case is a std::vector Which means that your code is basically translated into: extern std::vector<int> st; int* end = &st.back() + 1; int*

Does the iOS SDK provide queues and stacks?

心已入冬 提交于 2019-12-03 06:30:57
问题 I'm writing an iPhone app, and I'm surprised that there seem to be no NSQueue or NSStack classes in Apple's Foundation Framework. I see that it would be quite easy to roll my own, starting with an NSMutableArray, so I'll do that unless I've missed something. Have I missed something? 回答1: as far as I know there is no generic class avaialbe. Try using the NSMutableArray, add via addObject and get first/last via objectAtIndex and removeObjectAtIndex. 回答2: Here's my Stack class, in case it's

Is there a programmatic way to check stack corruption

浪子不回头ぞ 提交于 2019-12-03 06:30:28
I am working with a multithreaded embedded application. Each thread is allocated stack sizes based on its functionality. Recently we found that one of the thread corrupted the stack by defining a array of local variables that was more than the stack size. The OS is uItron. My solution, I registered a timer for 10 mS, and this timer will check for stack corruption. Stack corruption checking method, 1. Initialize the stack memory with some unique pattern (I use 0x5A5A5A5A) 2. Check from the time if top of the stack memory is still 0x5A5A5A5A My question, Is there a better way to check this type

App loses its ability to remember its stack when launched from another application

若如初见. 提交于 2019-12-03 06:18:54
问题 Now that I have researched this even more I am rewriting this to make it clearer. If you are looking for more info, there is some available in older edits. What is happening: (This refers to an application that has not set any launchMode settings and so is using the defaults) You launch an app from the Market or from the Installer. This launches the root/main activity of the application with the FLAG_ACTIVITY_NEW_TASK flag and no categories. Right now the applications stack is [ A ] Then you

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

混江龙づ霸主 提交于 2019-12-03 05:45:45
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, Locals=3, Args_size=1 0: aconst_null 1: astore_1 2: aconst_null 3: astore_2 4: return LineNumberTable:

C++: Stack's push() vs emplace() [duplicate]

泄露秘密 提交于 2019-12-03 05:41:34
问题 This question already has answers here : push_back vs emplace_back (6 answers) Closed 5 years ago . Trying to understand the difference between using push() or emplace() for std::stack . I was thinking that if I create a std::stack<int> , then I'd use push() because integer is a primitive type and there is nothing for emplace() to construct. However, if I was creating std::stack<string> then I'd choose emplace() because std::string is an object. Is this correct usage? 回答1: To fully understand

Why don't stacks grow upwards (for security)?

大憨熊 提交于 2019-12-03 05:36:33
问题 This is related to the question 'Why do stacks typically grow downwards?', but more from a security point of view. I'm generally referring to x86. It strikes me as odd that the stack would grow downwards, when buffers are usually written to upwards in memory. For example a typical C++ string has its end at a higher memory address than the beginning. This means that if there's a buffer overflow you're overwriting further up the call stack, which I understand is a security risk, since it opens