memory-management

Are resources used by a Java application freed when it terminates?

送分小仙女□ 提交于 2019-12-31 02:40:27
问题 Java applications may use IO streams, sockets or database connections that should be closed when they are no longer needed. However, applications may be terminated (e.g. by killing the process). Will all used resources be freed in this case? Who will free them: OS or JRE? 回答1: If your software doesn't take care of resource management properly, the following will happen: at runtime: the JVM will attempt during the duration of your program to close open streams if they're are seemingly unused

Linux kernel: Role of zero page allocation at paging_init time

余生长醉 提交于 2019-12-31 02:31:10
问题 I am trying to understand the kernel memory reservation at bootup for arch/arm. There's a call paging_init() for setting page tables, initialization of zone memory map etc in setup_arch() . It also allocate one zero page before allocating actual mem_map . void __init paging_init(const struct machine_desc *mdesc) { void *zero_page; --- zero_page = early_alloc(PAGE_SIZE); --- empty_zero_page = virt_to_page(zero_page); __flush_dcache_page(NULL, empty_zero_page); } Can someone please explain the

UIAlertView fails to show and results in “EXC_BAD_ACCESS” error

血红的双手。 提交于 2019-12-31 02:14:19
问题 A method is called when a return button on the keyboard is pressed. After calling another method which returns an integer a message is created based on that integer. The message is then passed into an UIAlterView and displayed to the user. The alert doesn't have any options (hence why I'm not calling a delegate), but simply notifies the user of what happened. Edit: Below is the full method (previously displayed partial). When I comment out everything before the UIAlertView and substitute the

Is the memory chunk returned by malloc (and its cousins) initialized to Zero?

喜欢而已 提交于 2019-12-30 20:58:03
问题 I wrote a code to test to stress test the memory management of Linux and Windows OS. Just for further tests I went ahead and checked what values are present in the memory returned by malloc(). The values that are being return are all 0 (zero). I have read the man page of malloc, checked on both Windows and Linux, but I am not able to find the reason for this behavior . According to the manpage the The malloc() function allocates size bytes and returns a pointer to the allocated memory. The

Is the memory chunk returned by malloc (and its cousins) initialized to Zero?

安稳与你 提交于 2019-12-30 20:57:47
问题 I wrote a code to test to stress test the memory management of Linux and Windows OS. Just for further tests I went ahead and checked what values are present in the memory returned by malloc(). The values that are being return are all 0 (zero). I have read the man page of malloc, checked on both Windows and Linux, but I am not able to find the reason for this behavior . According to the manpage the The malloc() function allocates size bytes and returns a pointer to the allocated memory. The

Is the memory chunk returned by malloc (and its cousins) initialized to Zero?

两盒软妹~` 提交于 2019-12-30 20:57:29
问题 I wrote a code to test to stress test the memory management of Linux and Windows OS. Just for further tests I went ahead and checked what values are present in the memory returned by malloc(). The values that are being return are all 0 (zero). I have read the man page of malloc, checked on both Windows and Linux, but I am not able to find the reason for this behavior . According to the manpage the The malloc() function allocates size bytes and returns a pointer to the allocated memory. The

Prevent an object from being paged out (VirtualLock equivalent)

大城市里の小女人 提交于 2019-12-30 20:53:22
问题 How would one go about keep an object in memory such that it won't be paged out by the OS in .Net? i.e. Something similar to VirtualLock, but operating on an object, such that if compacting occurs and the object is moved it still would not be paged out, etc.. (I suppose one could pin the object's, determine what pages it belongs to, and then VirtualLock those pages, but that seems non-desirable for many reasons.) If possible, could you point me to a reference or working sample? (C# ideally)

Swift: CGPathRelease and ARC

安稳与你 提交于 2019-12-30 18:26:13
问题 Just updated to Xcode Beta 4, and noticed the following compiler error with my code below: var path = CGPathCreateMutable() ... CGPathRelease(path) 'CGPathRelease' is unavailable: Core Foundation objects are automatically memory managed So do I simply just remove my release calls and everything should be fine? Or is there something more I'm missing? And are there any special cases I should be aware of with ARC? 回答1: The Working with Cocoa Data Types section of Using Swift with Cocoa and

Fortran 90 difference between compaq visual fortran and gfortran

吃可爱长大的小学妹 提交于 2019-12-30 16:27:12
问题 This may be a specific question, but I think it pertains to how memory is handled with these two compilers (Compaq visual Fortran Optimizing Compiler Version 6.5 and minGW). I am trying to get an idea of best practices with using pointers in Fortran 90 (which I must use). Here is an example code, which should work "out of the box" with one warning from a gfortran compiler: "POINTER valued function appears on RHS of assignment", and no warnings from the other compiler. module vectorField_mod

Why must I provide a dimension when passing a two-dimensional array to a C function?

痞子三分冷 提交于 2019-12-30 11:27:08
问题 I'm not sure if the history tag is relevant, but feel free to add it. I would presume the reason is historical, which is why I suggest this. Why is it that I cannot declare a function signature such as the following? void foo(int doubly_indexed_array[][]) { ... } which gives $ gcc mem.c mem.c:4: error: array type has incomplete element type Why must you declare one of the dimensions as in the following? void foo(int doubly_indexed_array[][10]) { ... } 回答1: You need to declare the second one