Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to find change in display ? Pin
User 665825-Apr-04 0:30
User 665825-Apr-04 0:30 
GeneralRe: How to find change in display ? Pin
Jijo.Raj25-Apr-04 3:11
Jijo.Raj25-Apr-04 3:11 
GeneralRe: How to find change in display ? Pin
grigsoft25-Apr-04 5:31
grigsoft25-Apr-04 5:31 
GeneralRe: How to find change in display ? Pin
Jijo.Raj25-Apr-04 21:03
Jijo.Raj25-Apr-04 21:03 
GeneralRe: How to find change in display ? Pin
grigsoft25-Apr-04 21:16
grigsoft25-Apr-04 21:16 
GeneralRe: How to find change in display ? Pin
Jijo.Raj26-Apr-04 2:40
Jijo.Raj26-Apr-04 2:40 
GeneralHow's about memory size usage Pin
nguyenvhn24-Apr-04 20:11
nguyenvhn24-Apr-04 20:11 
GeneralRe: How's about memory size usage Pin
Mike Nordell25-Apr-04 6:19
Mike Nordell25-Apr-04 6:19 
nguyenvhn wrote:
typedef struct{
CByteArray buff;
} my_struct;

typedef struct{
my_struct dat[30][10][10][3];
} data;

CArray<data, data&> my_arr;

From a cursory glance at MFC code, and unless I made a severe mistake:

You are aware that every element in my_arr is of type data, which is holding nine thousand CByteArray's? CByteArray's which each are of size 20 bytes and requires construction, including construction of parent class object CObject? So just one single instance of data at minimum requires 180.000 bytes.

For 'n' in your code you are:

1. Creating m = n * 9000 CByteArray's, for a total of at least m * 20 bytes.

2. Iterating over those m ByteArrays, calling SetSize for them, which allocates at least 16 (or is it 32, I really don't remember the allocation granularity of the SBH) bytes each, for a size of m*16 or m*32 bytes.

This becomes m*(20+16) or m*(20+32) bytes, minimum.

If n=1, you allocate at least 324.000 bytes.

If n=1000, you allocate at least 324.000.000 bytes.

Should SBH allocation granularity be 32, then you would get a memory load of about 446MB just to hold those nine million bytes. Should you use the debug heap, I think you can safely add another m*16 or m*32 bytes (for a memory load between 446 and 720MB respectively).

Just to create the nine million *holders* of the data, not the data itself, for the n=1000 case, you use 180 million bytes.

In my project, buff size is varying.

I suggest you at minimum should stop using MFC for collections (CByteArray even have a vfptr!), and start using a custom allocator.

In this case, which is my best solution (Using CArray or not)?

Not.

To be completely honest I'd say using any MFC collection class is almost always the wrong thing, but that's a completely different discussion.
GeneralRe: How's about memory size usage Pin
nguyenvhn25-Apr-04 21:23
nguyenvhn25-Apr-04 21:23 
GeneralRe: How's about memory size usage Pin
Mike Nordell26-Apr-04 4:14
Mike Nordell26-Apr-04 4:14 
GeneralRe: How's about memory size usage Pin
Paul Ranson25-Apr-04 6:45
Paul Ranson25-Apr-04 6:45 
GeneralRe: How's about memory size usage Pin
nguyenvhn25-Apr-04 21:38
nguyenvhn25-Apr-04 21:38 
GeneralRe: How's about memory size usage Pin
Paul Ranson26-Apr-04 1:16
Paul Ranson26-Apr-04 1:16 
GeneralRe: How's about memory size usage Pin
nguyenvhn26-Apr-04 15:16
nguyenvhn26-Apr-04 15:16 
GeneralHash Table Pin
Member 104413524-Apr-04 20:04
Member 104413524-Apr-04 20:04 
GeneralRe: Hash Table Pin
Garth J Lancaster24-Apr-04 21:38
professionalGarth J Lancaster24-Apr-04 21:38 
GeneralRe: Hash Table Pin
Prakash Nadar24-Apr-04 22:39
Prakash Nadar24-Apr-04 22:39 
GeneralRe: Hash Table Pin
DougW4824-Apr-04 21:50
DougW4824-Apr-04 21:50 
GeneralRe: Hash Table Pin
Garth J Lancaster25-Apr-04 1:08
professionalGarth J Lancaster25-Apr-04 1:08 
GeneralRe: Hash Table Pin
David Crow26-Apr-04 3:05
David Crow26-Apr-04 3:05 
GeneralService question Pin
tank102524-Apr-04 17:45
tank102524-Apr-04 17:45 
GeneralFunction/ read file Pin
Sarah Shy24-Apr-04 15:03
sussSarah Shy24-Apr-04 15:03 
GeneralRe: Function/ read file Pin
wb24-Apr-04 19:35
wb24-Apr-04 19:35 
GeneralRe: Function/ read file Pin
sarah shy25-Apr-04 3:27
susssarah shy25-Apr-04 3:27 
GeneralHELP WITH CODE Pin
Anonymous25-Apr-04 3:54
Anonymous25-Apr-04 3:54 

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.