Click here to Skip to main content
15,909,051 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Basic OOP Question Pin
Joaquín M López Muñoz4-Feb-02 6:24
Joaquín M López Muñoz4-Feb-02 6:24 
GeneralRe: Basic OOP Question Pin
AJ1237-Feb-02 1:23
AJ1237-Feb-02 1:23 
GeneralRe: Basic OOP Question Pin
Joaquín M López Muñoz7-Feb-02 2:13
Joaquín M López Muñoz7-Feb-02 2:13 
GeneralAvailable Comm Ports Pin
Steve Thresher4-Feb-02 6:12
Steve Thresher4-Feb-02 6:12 
GeneralRe: Available Comm Ports Pin
Rick York4-Feb-02 6:44
mveRick York4-Feb-02 6:44 
GeneralRe: Available Comm Ports Pin
Steve Thresher5-Feb-02 2:10
Steve Thresher5-Feb-02 2:10 
QuestionRestrictions of TreeControl under XP [or just another XP bug]? Pin
Andreas Saurwein4-Feb-02 5:56
Andreas Saurwein4-Feb-02 5:56 
QuestionWhat does an object REALLY look like? Pin
Jamie Hale4-Feb-02 5:51
Jamie Hale4-Feb-02 5:51 
Here's an interesting problem (I think)...

Our software uses a bunch (tens of thousands) of "slice" objects - each about 10k. Up until this morning, we were allocating them when we load the data file, and deallocating in the DeleteContents(). This causes a serious performance hit - it has been found that the allocation takes over 60% of the load time.

So I figured I'd just throw in a simple cache. I'd allocate a ton of slices up front, and just dish them out when I needed them. Did that, and now slice acquistion at load time is negligable.

The trouble is, I allocate slices in 10000 object chunks - that is, when the cache is exhausted, I run a for-loop 10000 times allocating a new slice each time. For some of our data files, this happens 4 or 5 times each load. I know this is inefficient, so I added another structure in the cache. When I need a new block, I allocate a 10000 * sizeof(slice) chunk, and handle the internal pointers myself.

No problem, right? In theory, this should speed up my load and access and whatnot a whole bunch... if it would just stop crashing. Smile | :)

Turns out, sizeof(object) just gives the size of the data members inside said object. My slice implements a custom interface full of pure virtual methods. sizeof() doesn't take into consideration the vtable and whatnot at the start of the class... Frown | :(

So my question is this: is there some way to determine (programmatically or through the compiler) exactly how large my object is so I can allocate a chunk of blank memory and manage my objects myself? Or should I just revert to the for loop?

Thanks.

J

AnswerRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 6:04
Joaquín M López Muñoz4-Feb-02 6:04 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 6:32
Jamie Hale4-Feb-02 6:32 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 7:25
Joaquín M López Muñoz4-Feb-02 7:25 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 7:56
Jamie Hale4-Feb-02 7:56 
GeneralRe: What does an object REALLY look like? Pin
4-Feb-02 8:05
suss4-Feb-02 8:05 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:34
Jamie Hale4-Feb-02 9:34 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 8:20
Joaquín M López Muñoz4-Feb-02 8:20 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:12
Jamie Hale4-Feb-02 9:12 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 9:22
Joaquín M López Muñoz4-Feb-02 9:22 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:32
Jamie Hale4-Feb-02 9:32 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:39
Jamie Hale4-Feb-02 9:39 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 11:21
Joaquín M López Muñoz4-Feb-02 11:21 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 18:25
Jamie Hale4-Feb-02 18:25 
GeneralRe: What does an object REALLY look like? Pin
4-Feb-02 9:48
suss4-Feb-02 9:48 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:50
Jamie Hale4-Feb-02 9:50 
GeneralRe: What does an object REALLY look like? Pin
4-Feb-02 11:19
suss4-Feb-02 11:19 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 18:17
Jamie Hale4-Feb-02 18:17 

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.