"User breakpoint called..."

Started by
14 comments, last by kirkd 21 years, 5 months ago
quote:Once I step out of the function will a non-pointer double which has been pushed into the vector still exist without any problems once the function exists


Yes, if ''desciptors'' is a member of the Observation class then it will exist until the Observation object is destroyed. Anything you''ve pushed back into it will be kept. The vector will resize itself to fit however many doubles you push into it. You could equally use a deque (double ended queue) if all you''re doing is pushing and popping. A stack would be best. However there isn''t one in vc++6.0 stl. There are in gcc and stlport I believe)

peace
Advertisement
i had this error once, and it dogged me for hours ''cause i had never gotten it before.

turns out i was overrunning an array that had been allocated just above the var i was getting the breakpoint on, not overrunning the var''s buffer itself.
Hmmmm...that is interesting....maybe I''m accessing something that''s been deleted (dynamic allocation and deleted) and it''s crunching into this code...hmmmm.....


petewood: yep you''re correct, a drunken typo. delete is diffenently the way forwards.

No more thoughts on why you''re getting the runtime error. But a thought on speed... new and delete have a large amount of overhead, if you''re calling the functions "hundreds of thousands of times" you''d be better off allocating hundreds (or thoudsands) of your base type in one go and having a simple method of determining if each element is in use (a structure of bool used and double value) - have a look at how particle code handles this.
Thanks for the tip. I didn''t realize new and delete were so costly. I haven''t noticed any problems with speed, thought. Whew!!

-Kirk
quote:Original post by Beelzebub
No more thoughts on why you''re getting the runtime error. But a thought on speed... new and delete have a large amount of overhead, if you''re calling the functions "hundreds of thousands of times" you''d be better off allocating hundreds (or thoudsands) of your base type in one go and having a simple method of determining if each element is in use

The obvious way of doing this would be to use a standard container, such as std::vector, and to reserve however much space you think you will need. Using vector in conjunction with boost::shared_ptr would probably have done the job without the OP ever encountering the problem he now has.

This topic is closed to new replies.

Advertisement