memory-management

What causes page fault and how to minimize them?

不羁岁月 提交于 2021-02-08 14:10:11
问题 When examining a process in Process Explorer, what does it mean when there are several page faults? The application is processing quite a bit of data and the UI is not very responsive. Are there optimizations to the code that could reduce or eliminate page faults? Would increasing the physical RAM of the system make a difference? 回答1: http://en.wikipedia.org/wiki/Page_fault Increasing the physical RAM on your machine could result in fewer page faults, although design changes to your

What causes page fault and how to minimize them?

邮差的信 提交于 2021-02-08 14:08:57
问题 When examining a process in Process Explorer, what does it mean when there are several page faults? The application is processing quite a bit of data and the UI is not very responsive. Are there optimizations to the code that could reduce or eliminate page faults? Would increasing the physical RAM of the system make a difference? 回答1: http://en.wikipedia.org/wiki/Page_fault Increasing the physical RAM on your machine could result in fewer page faults, although design changes to your

What causes page fault and how to minimize them?

↘锁芯ラ 提交于 2021-02-08 14:05:56
问题 When examining a process in Process Explorer, what does it mean when there are several page faults? The application is processing quite a bit of data and the UI is not very responsive. Are there optimizations to the code that could reduce or eliminate page faults? Would increasing the physical RAM of the system make a difference? 回答1: http://en.wikipedia.org/wiki/Page_fault Increasing the physical RAM on your machine could result in fewer page faults, although design changes to your

new[] doesn't decrease available memory until populated

狂风中的少年 提交于 2021-02-08 12:24:09
问题 This is in C++ on CentOS 64bit using G++ 4.1.2. We're writing a test application to load up the memory usage on a system by n Gigabytes. The idea being that the overall system load gets monitored through SNMP etc. So this is just a way of exercising the monitoring. What we've seen however is that simply doing: char* p = new char[1000000000]; doesn't affect the memory used as shown in either top or free -m The memory allocation only seems to become "real" once the memory is written to: memcpy

Allocating array of size 10^5 * 10^5 in c using malloc

杀马特。学长 韩版系。学妹 提交于 2021-02-08 12:06:46
问题 I asked the same problem two times (see here Getting segmentation fault while using malloc ) and improved my code. But I am unable to allocate memory for larger value of m and n . The heart of my code is : #include<stdio.h> #include<stdlib.h> int main() { int i,j,n,m,p = 0 ; int sum[100000] = {0}; scanf("%d%d%d",&n,&m,&p); /*for ( i = 0 ; i < n ; i++ ) { for( j = 0 ; j < m ; j++ ) { a[i][j] = j + 1 ; } }*/ int **a = malloc( n * sizeof *a ); for(i=0; i<n; i++) { a[i] = malloc( m * sizeof **a);

copying host memory to cuda __device__ variable

╄→гoц情女王★ 提交于 2021-02-08 08:47:10
问题 i've tried to find a solution to my problem using google but failed. there were a lot of snippets that didn't fit my case exactly, although i would think that it's a pretty standard situation. I'll have to transfer several different data arrays to cuda. all of them being simple struct arrays with dynamic size. since i don't want to put everything into the cuda kernel call, i thought, that __device__ variables should be exactly what i need. this is how i tried to copy my host data to the _

Which implementation to use when creating a List from Iterable

て烟熏妆下的殇ゞ 提交于 2021-02-08 08:20:19
问题 I find myself frequently doing the following: Iterator<A> itr = iterableOfA.getIterator(); List<B> list = new ArrayList<>(); // how about LinkedList? while (itr.hasNext()) { B obj = iter.next().getB(); list.add(obj); } someMethod(list); // this method takes an Iterable I have no idea just how many elements are likely to be in iterableOfA — could be 5, could be 5000. In this case, would LinkedList be a better implementation to use here (since list.add(obj) would then be O(1))? As it stands, if

Which implementation to use when creating a List from Iterable

纵然是瞬间 提交于 2021-02-08 08:19:31
问题 I find myself frequently doing the following: Iterator<A> itr = iterableOfA.getIterator(); List<B> list = new ArrayList<>(); // how about LinkedList? while (itr.hasNext()) { B obj = iter.next().getB(); list.add(obj); } someMethod(list); // this method takes an Iterable I have no idea just how many elements are likely to be in iterableOfA — could be 5, could be 5000. In this case, would LinkedList be a better implementation to use here (since list.add(obj) would then be O(1))? As it stands, if

Memory reallocation using mremap

余生长醉 提交于 2021-02-08 08:12:09
问题 I am trying to allocate two different 4096 bytes using malloc and initialize these allocations with different values. Afterwards, I want one of the pointers to point to the other allocation "without" changing the value of p1 and "without" copying the data. I want to "remap" the second allocation to the first allocation which should basically change the virtual address in the page table of the process, i.e. no copying is involved. When I run this code, I get that mremap failed. Any idea how to

Are members in a c++ class guaranteed be contiguous?

这一生的挚爱 提交于 2021-02-08 06:33:47
问题 Are class members in c++ guaranteed to be contiguous? I've tried running the following code with almost all popular c++ compilers, and all of them yield the result 4, which is the relative address of the variable y. Is that a coincidence, or is it guaranteed by the language specifications to be this way? Isn't it possible that the compiler will not make the members x and y contiguous with the class basic address/ contiguous with each other? Please note that this thread does not answer this