memory

Where the 'Type' of a reference value is stored in memory?

左心房为你撑大大i 提交于 2021-02-16 19:50:21
问题 As the reference values are stored in the heap as a data; where do the type information of any reference value is stored? If there are a couple of instances of class Artist; when they are stored in the heap how the .Net tags those memory blocks as type of Artist? thanks! 回答1: void M() { Artist a = new Artist(); } When the method is called, a new stack frame is expanded, CLR has some preparation code before the first statement of the method is executed, like a prolegomenon . During this period

Calculating average time for a memory access

戏子无情 提交于 2021-02-16 19:19:38
问题 I find it hard to understand the differences between the local and global miss rate and how to calculate the average time for a memory access and would just like to give an example of a problem that I have tried to solve. I would appreciate if someone could tell me if I'm on the right track, or if I'm wrong what I have missed. Consider the following multilevel cache hierarchy with their seek times and miss rates: L1-cache, 0.5 ns, 20% L2-cache, 1.8 ns, 5% L3-cache, 4.2 ns, 1.5% Main memory,

Current memory usage display is always ~14MB more than task manager

耗尽温柔 提交于 2021-02-11 15:21:16
问题 I'm currently using the code in this answer, with some slight modifications as suggested in the comments. However, no matter how many objects I allocate in memory, the listed memory usage is always ~14MB more than what task manager lists. Why could this be? std::stringstream ss; PROCESS_MEMORY_COUNTERS_EX pmc; GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc)); SIZE_T physMemUsedByMe = pmc.WorkingSetSize; ss << "\nMEM: " << (physMemUsedByMe / 1024 / 1024) <

String(const char*) constructor memory leak in string class

烈酒焚心 提交于 2021-02-11 14:00:58
问题 So I was trying to implement String class and I got an error saying segmentation fault. I think there is memory leak in my constructor. Can you please tell me what I am doing wrong? Thank you. here is the constructor code and I am not permitted to use any standard library functionality. String(const char* chars){ int i = 0; if(chars){ while(chars[i]){ i++; } } len = i; str = new char[len - 1]; for(int j = 0; j < len; j++){ str[j] = chars[j]; } }; And also this is my full code: #include

Determining if the running executable has IMAGE_FILE_LARGE_ADDRESS_AWARE?

狂风中的少年 提交于 2021-02-11 13:54:30
问题 Is there some sort of Windows API or other reasonably straightforward way to determine whether or not the currently running program has IMAGE_FILE_LARGE_ADDRESS_AWARE enabled? I know that I can open up the process's exe as a file, read its header information, and parse it somewhere out of there, but if there's some cleaner way to do it, I'd like to know. To be clear: I am talking about the currently executing process - i.e. I want to write code that detects this flag (or lack thereof) for its

Should I call `vkMapMemory` each time I write to a buffer?

自作多情 提交于 2021-02-11 13:36:12
问题 Are there any benefits to using a single vkMapMemory , a memset s for each write, and a single vkUnmapMemory as opposed to using a vkMapMemory , memset , and vkUnmapMemory for each write to a buffer? 回答1: Yes, it is beneficial to map only once. vkMapMemory likely needs to do some system calls, so it is not free. Authoritative quote, e.g. https://developer.samsung.com/game/usage#buffermanagement: Frequent Map/Unmap calls should be avoided. 来源: https://stackoverflow.com/questions/59118275

React - Can't find the leak, infinite state declaration suspected

ε祈祈猫儿з 提交于 2021-02-11 13:27:20
问题 I'm a complete beginner in React and I was pretty happy with my first app since I, maybe, have a memory leak ? My app is very laggy after entering value in the input, after click on the add button, at bottom right, and I suspect that I don't use 'useState' like I should ? I dunno, I've been searching for hours :( ... Here's the app : https://n3g.gitlab.io/react-conso-energie/ Here's the code : In the App.js (parent) : import React, { useState } from 'react' import firebase from './firebase'

React - Can't find the leak, infinite state declaration suspected

我的梦境 提交于 2021-02-11 13:25:46
问题 I'm a complete beginner in React and I was pretty happy with my first app since I, maybe, have a memory leak ? My app is very laggy after entering value in the input, after click on the add button, at bottom right, and I suspect that I don't use 'useState' like I should ? I dunno, I've been searching for hours :( ... Here's the app : https://n3g.gitlab.io/react-conso-energie/ Here's the code : In the App.js (parent) : import React, { useState } from 'react' import firebase from './firebase'

How much time does a program take to access RAM?

北城以北 提交于 2021-02-10 22:22:41
问题 I've seen explanations for why RAM is accessed in constant time ( O(1) ) and why it's accessed in logarithmic time ( O(n) ). Frankly neither makes much sense to me; what is n in the big-O notation and how does it make sense to measure the speed at which a physical device operates using big-O? I understand an argument for RAM being accessed in linear time is if you have an array a then the kth element would be at address a+k*size_of_type (point is address can be easily calculated). If you know

when does an operating system wipes out memory of a process

Deadly 提交于 2021-02-10 15:57:51
问题 A process is terminated successfully or abnormally on some OS, when does an OS decide to wipe out the memory (data, code etc.) allocated to that process; at exit or when it wants to allocate memory to a new process? And is this wiping out memory allocation procedure the same on all operating systems (winXP, Win7, linux, Mac)? I understand, page table has mapping of virtual addresses for that process and actual physical addresses in the memory. Thanks. 回答1: How an OS reclaims process resources