Click here to Skip to main content
15,897,704 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Drawing on button via DC Pin
jeron117-Apr-13 5:40
jeron117-Apr-13 5:40 
AnswerRe: Drawing on button via DC Pin
charlieg21-Apr-13 6:15
charlieg21-Apr-13 6:15 
AnswerRe: Drawing on button via DC Pin
daoxwj24-Apr-13 17:37
daoxwj24-Apr-13 17:37 
QuestionHow to place a bitmap on button? Pin
Member 989133417-Apr-13 2:59
Member 989133417-Apr-13 2:59 
AnswerRe: How to place a bitmap on button? Pin
David Crow17-Apr-13 4:21
David Crow17-Apr-13 4:21 
QuestionHBITMAP with alpha channel - what's wrong? Pin
Don Rolando16-Apr-13 21:08
Don Rolando16-Apr-13 21:08 
AnswerRe: HBITMAP with alpha channel - what's wrong? Pin
daoxwj24-Apr-13 17:40
daoxwj24-Apr-13 17:40 
QuestionUsing inactive memory to my advantage. What is this code storing in RAM or inactive memory? Pin
Member 999340116-Apr-13 18:18
professionalMember 999340116-Apr-13 18:18 
I'm developing on OS X 10.8.3. The following code is simple. It can perform two operations. If the read function is uncommented then the program will open the file at "address" and transfer all of its contents into data. If instead, the memcpy function is uncommented the program will copy the mmapped contents into data. I am developing on a mac which caches commonly used files in inactive memory of RAM for faster future access. I have turned off caching in both the file control and mmap becuase I am working with large files of 1 GB or greater. If i did not setup the NOCACHE option, the entire 1 GB would be stored in inactive memory.

If the read function is uncommented, the program behaves as expected. Nothing is cached and everytime the program is ran it takes about 20 seconds to read the entire 1 GB.

But if instead the memcpy function is uncommented something changes. Still i see no increase in memory and it still takes 20 seconds to copy on the first run. But every execution after the previous one, copies in under a second. This is very analogous to the behavior of caching the entire file in inactive memory, but I never see an increase in memory. Even if I then do not mmap the file and only perform a read, it performs in the same time, under a second.

Something must be getting stored in inactive memory, but what and how do I track it? I would like to find what is being stored and use it to my advantage.

I am using activity monitor to see a general memory size. I am using Xcode Instruments to compare the initial memcpy execution to an execution where both read and memcpy are commented. I see no difference in the Allocations, File Activity, Reads/Writes, VM Tracker, or Shared Memory tools.

XML
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>

int main(int argc, const char * argv[])
{
    unsigned char     *data;
    unsigned char     *mmapdata;
    size_t            length;

    int file = open("address", O_RDONLY);
    fcntl(file, F_NOCACHE, 1);

    struct stat st;
    stat("address", &st);
    length = st.st_size;

    data = malloc(length);
    memset(data,0,length);

    mmapdata = mmap(NULL, length, PROT_READ,MAP_SHARED|MAP_NOCACHE, file, 0);
    if (mmapdata == MAP_FAILED)
        fprintf(stderr, "failure");

//    read(file,data,length);
    close(file);

//    memcpy(data,mmapdata,length);
    munmap(mmapdata,length);

    free(data);

    return 0;
}

SuggestionRe: Using inactive memory to my advantage. What is this code storing in RAM or inactive memory? Pin
Richard MacCutchan16-Apr-13 21:13
mveRichard MacCutchan16-Apr-13 21:13 
GeneralRe: Using inactive memory to my advantage. What is this code storing in RAM or inactive memory? Pin
Member 999340117-Apr-13 11:10
professionalMember 999340117-Apr-13 11:10 
GeneralRe: Using inactive memory to my advantage. What is this code storing in RAM or inactive memory? Pin
Richard MacCutchan17-Apr-13 22:24
mveRichard MacCutchan17-Apr-13 22:24 
QuestionGetting thread handle from hWnd in Windows CE 5.0 Pin
Member 989133416-Apr-13 3:37
Member 989133416-Apr-13 3:37 
AnswerRe: Getting thread handle from hWnd in Windows CE 5.0 Pin
dusty_dex16-Apr-13 6:29
dusty_dex16-Apr-13 6:29 
QuestionMy counter only count to 1. Pin
Søren Lyder Nielsen16-Apr-13 3:12
Søren Lyder Nielsen16-Apr-13 3:12 
AnswerRe: My counter only count to 1. Pin
NotPolitcallyCorrect16-Apr-13 3:15
NotPolitcallyCorrect16-Apr-13 3:15 
AnswerRe: My counter only count to 1. Pin
Maximilien16-Apr-13 3:19
Maximilien16-Apr-13 3:19 
GeneralRe: My counter only count to 1. Pin
Søren Lyder Nielsen16-Apr-13 21:31
Søren Lyder Nielsen16-Apr-13 21:31 
AnswerRe: My counter only count to 1. Pin
Erudite_Eric16-Apr-13 4:50
Erudite_Eric16-Apr-13 4:50 
AnswerRe: My counter only count to 1. Pin
dusty_dex16-Apr-13 21:54
dusty_dex16-Apr-13 21:54 
QuestionHow to resize tab controls in mfc.? Pin
mbatra3116-Apr-13 1:18
mbatra3116-Apr-13 1:18 
AnswerRe: How to resize tab controls in mfc.? Pin
_AnsHUMAN_ 16-Apr-13 3:10
_AnsHUMAN_ 16-Apr-13 3:10 
AnswerRe: How to resize tab controls in mfc.? Pin
Coder Block16-Apr-13 20:08
Coder Block16-Apr-13 20:08 
QuestionAbout strings in c language Pin
Ajay kumar124715-Apr-13 23:44
Ajay kumar124715-Apr-13 23:44 
AnswerRe: About strings in c language Pin
Richard MacCutchan15-Apr-13 23:48
mveRichard MacCutchan15-Apr-13 23:48 
AnswerRe: About strings in c language Pin
Sivaraman Dhamodharan16-Apr-13 0:14
Sivaraman Dhamodharan16-Apr-13 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.