memory-management

Difference between 3rd gen objects and large object heap

只谈情不闲聊 提交于 2020-01-02 06:25:17
问题 What is the difference between large object heap and GC 3rd generation objects? 回答1: The LOH (Large Object Heap) is a single heap where large objects are allocated directly and stay there until they are collected. Objects are directly allocated into the LOH based on their size e.g. being equal or greater than 85000 bytes. Generational objects are "small" objects that are allocated into the SOH (Small Object Heap) which is a single heap. Objects in the SOH have an associated generation which

Virtually contiguous vs. physically contiguous memory

情到浓时终转凉″ 提交于 2020-01-02 05:47:09
问题 Is virtually contiguous memory also always physically contiguous? If not, how is virtually continuous memory allocated and memory-mapped over physically non-contiguous RAM blocks? A detailed answer is appreciated. 回答1: Short answer: You need not care (unless you're a kernel/driver developer). It is all the same to you. Longer answer: On the contrary, virtually contiguous memory is usually not physically contiguous (only in very small amounts). Except by coincidence, or shortly after the

After adding request_mem_region my driver fails every first access with “busy” message

对着背影说爱祢 提交于 2020-01-02 05:24:11
问题 OK, this is really weird to me. I've got a simulated CAN bus driver, it is a Linux Kernel module. Then I have a test application running in user space which accesses the driver via opening a file descriptor and sending ioctl() messages. Now the CAN bus driver is just something I've been adopting to run on the x86 platform (it was running on our embedded Coldfire system). On the embedded system it had to use request_mem_region() / ioremap() to get the memory I/O area accessible, I don't need

Freeing memory used by unattached DOM nodes in Javascript

折月煮酒 提交于 2020-01-02 04:50:28
问题 As part of my application, I'm putting together a set of small Dom nodes that are not shown all at once. I'm storing them in an internal array. The user can invoke their display in which case I reparent them to the div that is used to display them. That's all well and good. But when it's time to replace all of them with new ones, I want to destroy the old ones (effectively deallocate them). Otherwise, over time, memory usage could grow exponentially. How do I force the browser js engine to do

Are custom blocks ever copied by OCaml?

[亡魂溺海] 提交于 2020-01-02 04:44:11
问题 Imagine I've a C library called libcat for interacting with my cat fluffy. I'm therefore writing bindings for OCaml to simplify interactions with fluffy. module type CAT = sig type cat val find : ... -> cat val feed : cat -> unit ... end ;; module Cat : CAT = ... There is considerable memory management already built into libcat, like say caching, freeing destroyed toys, and maybe even a limited scope garbage collector for emptying the litter. Yet, overall libcat requires that users explicitly

How to free an array in C/C++ [closed]

有些话、适合烂在心里 提交于 2020-01-02 04:38:27
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . int main() { // Will this code cause memory leak? // Do I need to call the free operator? // Do I need to call delete? int arr[3] = {2, 2, 3}; return 0; } Does this code create a memory leak? Where does arr reside? On the stack or in RAM? 回答1: In this program int main() { // Will

What the difference between (*T)(nil) and &T{}/new(T)? Golang

给你一囗甜甜゛ 提交于 2020-01-02 04:27:11
问题 Could anybody explain what the subtle difference between these two notations: (*T)(nil)/new(T) and &T{} . type Struct struct { Field int } func main() { test1 := &Struct{} test2 := new(Struct) test3 := (*Struct)(nil) fmt.Printf("%#v, %#v, %#v \n", test1, test2, test3) //&main.Struct{Field:0}, &main.Struct{Field:0}, (*main.Struct)(nil) } Seems like the only difference of this one (*T)(nil) from other is that it returns nil pointer or no pointer, but still allocates memory for all fields of the

how does the OS know the real size of the physical memory?

佐手、 提交于 2020-01-02 04:25:15
问题 When the OS is loaded at the moment the computer is started, how does the OS know the hardware information, is there some io instruction or the booter program get information from the bios.?? 回答1: The motherboard firmware (also called BIOS, ACPI interface or EFI) allows the OS to find out the physical mapping of RAM and ROM in the system. For example, this is the output of a booting Linux: [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: 0000000000000000 - 0000000000098c00

const char* and free()

空扰寡人 提交于 2020-01-02 04:15:14
问题 Given the next code example, I'm unable to free the parameter const char* expression : // removes whitespace from a characterarray char* removewhitespace(const char* expression, int length) { int i = 0, j = 0; char* filtered; filtered = (char*)malloc(sizeof(char) * length); while(*(expression + i) != '\0') { if(!(*(expression + i) == ' ')) { *(filtered + j) = *(expression + i); j++; } i++; } filtered[j] = '\0'; free(expression); //this doesn't seem to work return filtered; } Before I return

Difference between memory_get_peak_usage and actual php process' memory usage

左心房为你撑大大i 提交于 2020-01-02 04:13:30
问题 Why result of php memory_get_peak_usage differs so much from memory size that is shown as allocated to process when using 'top' or 'ps' commands in Linux? I've set 2 Mb of memory_limit in php.ini My single-string php-script with echo memory_get_peak_usage(true); says that it is using 786432 bytes (768 Kb) If I try to ask system about current php process echo shell_exec('ps -p '.getmypid().' -Fl'); it gives me F S UID PID PPID C PRI NI ADDR SZ WCHAN RSS PSR STIME TTY TIME CMD 5 S www-data