MantisBT - Community
View Issue Details
0002499Community[OCCT] OCCT:Foundation Classespublic2003-04-28 15:242011-11-29 10:57
bugmaster 
szy 
normaltrivial 
closedfixed 
All
 
[OCCT] 5.1.0 
0002499: The assignation operator for all the maps assignation is bugged
Bug from Open CASCADE community

Autors: Joel Donneux & Ivan Fontaine

http://www.opencascade.org/forumorg/bug.php?bug_id=118&f=8 [^]

Well, a new candidate for the "Bug of Year" contest.

The assignation operator for all the maps assignation is bugged.
The destination map is resized using the number of buckets of the
map. The result of this is that during an assignation all the destination maps
are sized to the "NextPrime" size.

If you have a map with one element and if you copy it 26 times,
you end up with a map having 100019 buckets to store one element.

And if your application has some map of maps and that you use CAF,
you can potentially use hundreds of mega bytes to store a few Standard_Integer
!!

Needless to say, Cascade is rather memory hungry, and this bug makes
the situation even worst.


You should alter all your maps definitions in a way like this:

TCollection_Map& TCollection_Map::Assign(const TCollection_Map& Other)
{
if (this == &Other) return *this;
Clear();
 // **** modif
// ReSize() uses the TCollection::NextPrimeForMap() to get the next bucket size,
// so, the bucket size grows at each copy, even in the number of object
// in the map is constant !
//
// ReSize(Other.NbBuckets());
//
if (!Other.IsEmpty()) {
ReSize(Other.Extent());
// **** END modif
for (TCollection_MapIterator It(Other); It.More(); It.Next()) {
Add(It.Key());
}
}
return *this;
}


Joel Donneux & Ivan Fontaine
No tags attached.
gz B2499.tar.gz (4,610) 2003-05-07 15:52
https://tracker.dev.opencascade.org/
Issue History
2003-04-28 15:25bugmasterAssigned Tobugmaster => szy
2003-04-28 15:25bugmasterStatusnew => assigned
2003-04-28 15:25bugmasterSummary => The assignation operator for all the maps assignation is bugged
2003-05-12 19:46bugmasterStatusassigned => resolved
2003-05-15 20:19apvCC => apv
2003-05-15 20:20apvCC => aki
2003-05-23 22:18akiStatusresolved => tested
2003-06-02 12:13bugmasterStatustested => closed
2003-06-02 12:13bugmasterResolution@0@ => fixed
2004-12-30 11:32bugmasterCustomer =>
2011-08-02 11:23bugmasterCategoryOCCT:FDC => OCCT:Foundation Classes
2011-11-29 10:57bugmasterDescription Updatedbug_revision_view_page.php?rev_id=1140#r1140

There are no notes attached to this issue.