memory

Does memmove use dynamic memory for its temporary array

£可爱£侵袭症+ 提交于 2020-01-04 05:36:11
问题 According to C11 N1570 standard draft: 7.24.2.2 "The memmove function": The memmove function copies n characters from the object pointed to by s2 into the object pointed to by s1 . Copying takes place as if the n characters from the object pointed to by s2 are first copied into a temporary array of n characters that does not overlap the objects pointed to by s1 and s2 , and then the n characters from the temporary array are copied into the object pointed to by s1 So if I choose to move a

Android 启动过程简析

时光怂恿深爱的人放手 提交于 2020-01-04 05:27:28
首先我们先来看android构架图: android系统是构建在linux系统上面的。 所以android设备启动经历3个过程。 Boot Loader,Linux Kernel & Android 系统服务。 1.基本启动过程 系统引导bootloader 加载boot.img 由bootloader 加载内核kernel 文件系统挂载,init 完成引导进程(文件解析、属性设置、启动服务、执行动作) 重要的服务进程zygote 建立Java Runtime,建立虚拟机 启动Android System Server 系统服务System Server 通过System Manager管理android的服务 桌面launcher 各个服务已经就绪,桌面程序Home在ActivityManagerService的服务过程中建立 2.init android 启动流程图: 是有kernel启动的第一个进程。 用来完成其他服务的引导进程。 init启动的过程记录在init.rc文件中。 2.1 init.rc的语法 rc文件只有在System/Core/Init/readme.txt中有描述 一共分为4种设计。 Action Commands Services Options Action & Services 暗示着一个新的语句的开始,这两个关键字后面跟着的 commands 或者

Cache coherence issues in a DMA context

淺唱寂寞╮ 提交于 2020-01-04 05:26:21
问题 Suppose the CPU modifies the value in location x+50 and does not flush it back to main memory(write-back). Meanwhile, a device launches a DMA read request from x to x+100. In that case, how the CPU is informed to flush back the dirty cache line? 回答1: The DMA circuitry often works directly with the main memory without involving the CPU (and that's the main idea, to free the CPU from doing I/O that can be done elsewhere in the hardware and thus save CPU cycles). So, you may indeed run into

Hoard memory allocator

大城市里の小女人 提交于 2020-01-04 05:12:14
问题 Hoard memory allocator I'm reading papers about Hoard memory allocator, and everything is understandable, but one thing not, how it reduces contention for the heap caused when multiple threads allocate or free memory, after avoids the false sharing that can be introduced by memory allocators and at the same time, it applies strict bounds on fragmentation. How did they achieve it? 回答1: From the paper, Hoard allocates memory internally in superblocks as required by the per-processor heaps .

Crash when handling char * init'd with string literal, but not with malloc

左心房为你撑大大i 提交于 2020-01-04 05:04:36
问题 I was reading a book on C today, and it mentioned that the following was true; I was so curious as to why that I made this program to verify; and then ultimately post it here so someone smarter than me can teach me why these two cases are different at runtime. The specifics of the question related to the difference at runtime between how a (char *) is handled based on whether it is pointing to a string created as a literal vs. created with malloc and manual population. why is the memory

How to emulate the process of a background activity is killed by the system because of low memory on Android?

99封情书 提交于 2020-01-04 04:16:25
问题 I'm dealing with the "Low memory: no more background process" problem. My activity is at background and killed when the situation occurs. I'm trying to save and load the instance state to solve it. But since it doesn't happen every time. How should I test my activity with this situation? Thanks! 回答1: You can force your process to die through adb. > adb shell # ps # kill -9 <pid> where <pid> is the process id of your app. Caveat: I don't know if this method of ending the process is the same as

Understanding Shared Memory Using C

懵懂的女人 提交于 2020-01-04 02:54:32
问题 Using C, I'm trying to set up shared memory. My code looks like: key_t key = ftok("SomeString", 1); static int *sharedval; int shmid = shmget(key, sizeof(int), S_IRUSR | S_IWUSR); // less permissions sharedval = (int *) shmat(shmid, NULL, 0); *sharedval = 0; However the second I run that last line, I get a segmentation fault. When debugging, I can print "sharedval" and I get a memory address, presumably the place in memory I got. So I would assume all I have to do is use *sharedval to assess

browser memory increasing constantly with javascript ajax calls

☆樱花仙子☆ 提交于 2020-01-04 02:12:08
问题 I have a strange behaviour. I am using a rather heavy page (4000 nodes) meant to display a dispatch system for delivery operations. Every 30 sec. I am refreshing with jquery, the list of operations (3000 nodes over 4000). It works perfectly well, but... each time, the memory of both firefox and chrome is increasing by 3 to 6ko. Of course, after a while, the browser crashes... Does anybody have any kind of idea why? Is it a memory leak? Does javascript fail to somewhere? I checked, and after

Thread-safe implementation of the Copy-on-write (COW) idiom?

十年热恋 提交于 2020-01-04 02:09:09
问题 Can anyone point me to a thread-safe implementation of the Copy-on-write (COW) idiom? The sample code on this site looks good -- is it thread-safe? In case anyone is wondering what I will be using it for: I have a Foo class that has a std::map<int,double> member. Foo objects are copied very frequently in my code, but the copies rarely modify the contained map . I found that COW gives me a 22% performance boost, compared to copying the whole map contents in the Foo copy constructor, but my COW

Java - Why forced garbage collection doesn't release memory

倖福魔咒の 提交于 2020-01-04 02:06:13
问题 I am generating a large data structure and write it to hard disk. Afterwards I want to get rid of the object, to reduce the memory consumption. My problem is that after I had forced a garbage collection the amount of used memory is at least as high as it was before garbage collection. I have added a minimal working example what I am doing. DataStructure data = new DateStructure(); data.generateStructure(pathToData); Writer.writeData(data); WeakReference<Object> ref = new WeakReference<Object>