memory

How does IOS manage memory of backgrounded apps?

你离开我真会死。 提交于 2021-01-29 06:55:28
问题 I have an IOS app that during testing seems to work fine until... The app has been in the background for quite some time, say 24 hours... and meanwhile lots of activity has taken place in other apps (videos, audio, location... battery going low... lots of memory being used). Then when I bring my app back into the foreground, it acts glitchy such as having no audio... and then crashes after a short while. I KNOW this is not the best description, but it has only happened once and I'm not asking

Assigning unsigned char* buffer to a string

喜你入骨 提交于 2021-01-29 06:03:20
问题 This question might be asked before but I couldn't find exactly what I need. My problem is, I have a buffer loaded by data downloaded from a webservice. The buffer is in unsigned char* form in which there is no '\0' at the end. Then I have a poco xml parser needs a string. I tried assigning it to string valgrind found some lost data. (see below) here is the code: DOMParser::DOMParser(unsigned char* consatData, int consatDataSize, unsigned char* lagData, int lagDataSize) { Poco::XML::DOMParser

JVM “EXCEPTION_ACCESS_VIOLATION” crash in Spring Boot application

南笙酒味 提交于 2021-01-29 05:40:25
问题 JVM Crash - "EXCEPTION_ACCESS_VIOLATION" I made this CLI tool using Spring Boot and it takes a long time to run. I usually let it run overnight. Then, for several times I came across this JVM crash, and I don't know what to look for in there. I have seen other error reports on SO, but could not relate those to mine. Can you please take a look at this log file? Bear in mind I have been having problems with memory leak in the app... I have started suffering from this error when I thought I had

Matrix/Vector initialization performance

こ雲淡風輕ζ 提交于 2021-01-29 05:29:30
问题 This is more of an educational question, there is no specific problem I am trying to solve. I would like some insight into what happens "behind the scenes" in the following scenario: We have 2 int s, w and h , and we need a matrix ( vector<vector<int>> ) of 0 s. There are multiple ways to do this and I would like to know which one performs best (probably this means which one performs the least copies). Option 1: vector<vector<int>> m; for (int i = 0; i < h; i++) { m.push_back(vector<int>());

Scavenger: Allocation failed - JavaScript heap out of memory

蓝咒 提交于 2021-01-29 04:31:02
问题 Here's the error message: <--- Last few GCs ---> [2383:0x7efe08001450] 6100 ms: Scavenge 30.3 (39.5) -> 30.5 (42.7) MB, 73.5 / 0.0 ms (average mu = 1.000, curr ent mu = 1.000) allocation failure [2383:0x7efe08001450] 8464 ms: Scavenge 35.1 (44.5) -> 35.3 (44.8) MB, 2336.2 / 0.0 ms (average mu = 1.000, cu rrent mu = 1.000) allocation failure [2383:0x7efe08001450] 32349 ms: Scavenge 36.1 (44.8) -> 36.0 (45.8) MB, 23879.5 / 0.2 ms (average mu = 1.000, c urrent mu = 1.000) allocation failure <---

Local variables and memory in c

二次信任 提交于 2021-01-29 03:04:17
问题 I'm somewhat new to C and am wondering about certain things about memory allocation. My function is as follows: size_t count_nwords(const char* str) { //char* copied_str = strdup(str); // because 'strtok()' alters the string it passes through char copied_str[strlen(str)]; strcpy(copied_str, str); size_t count = 1; strtok(copied_str, " "); while(strtok(NULL, " ") != 0) { count++; } //free(copied_str); return count; } This function counts the amount of words in a string (the delimiter is a

Efficient use of boolean true and false in C++?

对着背影说爱祢 提交于 2021-01-28 21:43:53
问题 Would any compiler experts be able to comment on the efficient use of boolean values? Specifically, is the compiler able to optimize a std::vector<boolean> to use minimal memory? Is there an equivalent data structure that would? Back in the day, there were languages that had compilers that could compress an array of booleans to a representation of just one bit per boolean value. Perhaps the best that could be done for C++ is to use std::vector<char> to store the boolean values for minimal

Efficient use of boolean true and false in C++?

廉价感情. 提交于 2021-01-28 21:06:39
问题 Would any compiler experts be able to comment on the efficient use of boolean values? Specifically, is the compiler able to optimize a std::vector<boolean> to use minimal memory? Is there an equivalent data structure that would? Back in the day, there were languages that had compilers that could compress an array of booleans to a representation of just one bit per boolean value. Perhaps the best that could be done for C++ is to use std::vector<char> to store the boolean values for minimal

Understanding linker script NOLOAD sections in embedded software

耗尽温柔 提交于 2021-01-28 20:01:01
问题 According to the GNU documentation for ld , a NOLOAD section works as following: The `(NOLOAD)' directive will mark a section to not be loaded at run time. The linker will process the section normally, but will mark it so that a program loader will not load it into memory. Now, regarding to the program loader , accordign to wikipedia: Embedded systems typically do not have loaders, and instead, the code executes directly from ROM. In order to load the operating system itself, as part of

Accessing struct elements using single pointer?

泄露秘密 提交于 2021-01-28 19:51:06
问题 I have defined 5 floats within a struct: struct as {float a1, a2, a3, a4, a5;}; I'd like to access those 5 using a single pointer float* p_a = &a1; , and then just p_a++ , etc. Will it work? Converting to array float a[5] requires a big change I would like to avoid. 回答1: I would rather typedef struct { union { float fa[5]; struct { float f1,f2,f3,f4,f5; }; }; /* .... */ }MY_T; void foo() { MY_T s; float *p = s.fa; p++ *p = something; } 回答2: You can do ++ on array-element pointers and as long