memory-management

How do I find the physical memory size in Java?

て烟熏妆下的殇ゞ 提交于 2020-01-11 04:27:09
问题 I'm writing an installer that will tune the configuration of the product for the particular hardware on which it will be run. In particular, I want to determine how much physical RAM is installed in the system so I can estimate how much memory to allocate to the product when it runs. Ideally, I'd like to do this in a platform-independent, pure Java way, as the installer will need to run on several different platforms, but in case this isn't possible, solutions for Windows are preferred as

Why does malloc allocate more memory spaces than I ask for? [duplicate]

一笑奈何 提交于 2020-01-11 04:06:05
问题 This question already has answers here : Malloc vs custom allocator: Malloc has a lot of overhead. Why? (3 answers) Closed 3 years ago . I found that malloc() allocates more memory spaces than I ask for. struct { void *ptr; int var; } msg; // 16 bytes (checked by sizeof()) for (int i = 0; i < 100000000; i++) malloc(sizeof(msg)); As the aforementioned code, malloc() actually allocate 32 bytes per function call (calculated by top ), but valgrind shows only 16 bytes per call indeed. Why does

Is explicitly clearing/zeroing sensitive variables after use sensible?

扶醉桌前 提交于 2020-01-11 00:11:09
问题 I have noticed some programs explicitly zero sensitive memory allocations after use. For example, OpenSSL has a method to clear the memory occupied by an RSA key: "Frees the RSA structure rsa. This function should always be used to free the RSA structure as it also frees sub-fields safely by clearing memory first." http://www.rsa.com/products/bsafe/documentation/sslc251html/group__COMMON__RSA__KEY__FUNCS.html#aRSA_free Where any (C/C++) program contains sensitive variables like this, should

Visual Studio 2010 — how to reduce its memory footprint

故事扮演 提交于 2020-01-10 22:04:59
问题 I have a solution with just under 100 projects in it, a mix of C++ and C# (mostly C#). When working in VS2005, the working set of Visual Studio is considerably smaller than that of VS2010. I was wondering if there are some things that can be turned off, so I can develop in VS2010 under 32-bit OS without running out of memory. 回答1: You can try using the Solution Load Manager. It'll let you mark some of the projects files as load on demand or not load at all. That may help. 回答2: A 64-bit OS

Visual Studio 2010 — how to reduce its memory footprint

谁说胖子不能爱 提交于 2020-01-10 22:04:23
问题 I have a solution with just under 100 projects in it, a mix of C++ and C# (mostly C#). When working in VS2005, the working set of Visual Studio is considerably smaller than that of VS2010. I was wondering if there are some things that can be turned off, so I can develop in VS2010 under 32-bit OS without running out of memory. 回答1: You can try using the Solution Load Manager. It'll let you mark some of the projects files as load on demand or not load at all. That may help. 回答2: A 64-bit OS

Standard library facilities which allocate but don't use an Allocator

别等时光非礼了梦想. 提交于 2020-01-10 14:15:15
问题 In most places where the C++ standard library allocates memory, the user is able to customise this by providing a class which meets the Allocator requirements. For example, almost all containers take an allocator template argument, and std::allocate_shared returns a shared_ptr whose contained element and control block are both allocated via a provided Allocator. However, there are a few places where the standard library can (potentially) allocate memory, but no Allocator support is provided.

Assembly memory allocation

南笙酒味 提交于 2020-01-10 10:15:50
问题 I am trying to learn assembly language and I need clarification on something. Please correct me if I am wrong on any of this since I don't know much about assembly. All the tutorials I watch have the variables of assembly programs assigned to a memory address like 0x0000 , and I can understand that you must manually assign memory addresses in assembly, but how do you know what address to use? Obviously it makes sense to start at the lowest memory address possible, but what if the variable you

Difference between Cache and Translation LookAside Buffer[TLB]

ぐ巨炮叔叔 提交于 2020-01-10 08:49:52
问题 What is the difference between Cache and Translation LookAside Buffer [TLB] ? 回答1: From Wiki: In computer science, a cache (pronounced /kæʃ/, kash) is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch (owing to longer access time) or to compute, compared to the cost of reading the cache. In other words, a cache operates as a temporary storage area where frequently accessed data can be stored for rapid access.

C++ string memory management

断了今生、忘了曾经 提交于 2020-01-10 08:29:10
问题 Last week I wrote a few lines of code in C# to fire up a large text file (300,000 lines) into a Dictionary. It took ten minutes to write and it executed in less than a second. Now I'm converting that piece of code into C++ (because I need it in an old C++ COM object). I've spent two days on it this far. :-( Although the productivity difference is shocking on its own, it's the performance that I would need some advice on. It takes seven seconds to load, and even worse: it takes just exactly

memory allocation in Stack and Heap

℡╲_俬逩灬. 提交于 2020-01-10 07:58:14
问题 This may seem like a very basic question, but its been in my head so: When we allocate a local variable, it goes into stack. Similarly dynamic allocation cause the variable to go on heap. Now, my question is, is this variable actually lie on stack or heap or we will just a reference in the stack and Heap. For example, Suppose I declare a variable int i . Now this i is allocated on the stack. So, when I print the address of i , this will be one of the location on stack? Same question for heap