Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: old fashioned memory access in a visual C++ console application? Pin
Gary R. Wheeler1-Mar-03 2:48
Gary R. Wheeler1-Mar-03 2:48 
GeneralRe: old fashioned memory access in a visual C++ console application? Pin
Anonymous1-Mar-03 10:01
Anonymous1-Mar-03 10:01 
GeneralRe: old fashioned memory access in a visual C++ console application? Pin
Gary R. Wheeler1-Mar-03 14:20
Gary R. Wheeler1-Mar-03 14:20 
AnswerRe: old fashioned memory access in a visual C++ console application? Pin
dim136-Jan-05 2:05
dim136-Jan-05 2:05 
GeneralImPLEMENT_DYNAMIC Pin
ns27-Feb-03 7:54
ns27-Feb-03 7:54 
GeneralRe: ImPLEMENT_DYNAMIC Pin
Dave Bryant27-Feb-03 8:24
Dave Bryant27-Feb-03 8:24 
Generalthanks! Pin
ns27-Feb-03 8:32
ns27-Feb-03 8:32 
GeneralEfficient use of memory and filtering Pin
Anton A. Loukine27-Feb-03 6:41
Anton A. Loukine27-Feb-03 6:41 
Hi!

I need to create a routine that screens a large population stored in an array and creates a smaller sample of items that pass certain criteria. My original approach was as follows:
- Run through the population the flag the items that pass the criteria (counting the number of items that passed at the same time);
- Allocate an array for a smaller sample (use the element count obtained earlier);
- Go through the population again and, for all flagged elements, copy pointers to these elements from the population to the sample (unflag the elements as we go);

Well this seems to do the trick but it requires me to pass through the array twice and do a lot of flagging/unflagging. I am wondering if I can do the following instead (and if it's going to be any faster):
- Allocate an array for the sample equal in size to the population (we know that this is as large as it can theoretically get).
- Go through the elements in the population and copy pointers to the sample array at the same time (no flagging/unflagging).
- Release the unused block of memory from the sample array without affecting the initial elements (e.g, if I used 50 elements from 100 allocated, release the block for 51 - 100).

Releasing the unused block is where I am lost. Do I have to use delete[n] for all n = 51 - 100? or is there a better way to let the operating system know that it can have that piece of memory back? Is the second approach going to be anymore efficient than the first?

One more thing: the population array must be preserved.

Thanks a lot?
GeneralRe: Efficient use of memory and filtering Pin
John M. Drescher27-Feb-03 6:50
John M. Drescher27-Feb-03 6:50 
GeneralRe: Efficient use of memory and filtering Pin
Anton A. Loukine27-Feb-03 7:20
Anton A. Loukine27-Feb-03 7:20 
GeneralRe: Efficient use of memory and filtering Pin
Daniel Turini27-Feb-03 7:34
Daniel Turini27-Feb-03 7:34 
GeneralRe: Efficient use of memory and filtering Pin
John M. Drescher27-Feb-03 7:48
John M. Drescher27-Feb-03 7:48 
QuestionAutomatic generation of MS Visual C++ projects ? Pin
CHARMAN27-Feb-03 6:19
CHARMAN27-Feb-03 6:19 
AnswerRe: Automatic generation of MS Visual C++ projects ? Pin
AlexO27-Feb-03 8:21
AlexO27-Feb-03 8:21 
GeneralSHGetFileInfo: I can't get SHGFI_ICONLOCATION to work Pin
Mike Morearty27-Feb-03 6:15
Mike Morearty27-Feb-03 6:15 
GeneralRe: SHGetFileInfo: I can't get SHGFI_ICONLOCATION to work Pin
AlexO27-Feb-03 8:38
AlexO27-Feb-03 8:38 
GeneralRe: SHGetFileInfo: I can't get SHGFI_ICONLOCATION to work Pin
Mike Morearty27-Feb-03 8:49
Mike Morearty27-Feb-03 8:49 
GeneralCSliderCtrl notifications Pin
Maximilien27-Feb-03 5:25
Maximilien27-Feb-03 5:25 
GeneralRe: CSliderCtrl notifications Pin
AlexO27-Feb-03 5:59
AlexO27-Feb-03 5:59 
Generalmultiple windowed apps Pin
SumGuy27-Feb-03 5:19
SumGuy27-Feb-03 5:19 
GeneralRe: multiple windowed apps Pin
Rage27-Feb-03 5:55
professionalRage27-Feb-03 5:55 
GeneralRe: multiple windowed apps Pin
SumGuy27-Feb-03 6:26
SumGuy27-Feb-03 6:26 
GeneralI figured it out thanks Pin
SumGuy27-Feb-03 7:19
SumGuy27-Feb-03 7:19 
GeneralRe: I figured it out thanks Pin
Alvaro Mendez27-Feb-03 9:54
Alvaro Mendez27-Feb-03 9:54 
GeneralRe: I figured it out thanks Pin
Jason Henderson27-Feb-03 11:22
Jason Henderson27-Feb-03 11:22 

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.