473,803 Members | 3,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stdext::hash_ma p

problem with deleting big sized hash_map.
have defined a comporator, where defined min_bucket_size (for speed
improvement, since i know that i need to store big ammount of data
(~1Mln)), everything seems to be good, working fast, but problems start
when try to .clear() or delete that hash_map... I think that it just
take ennormous amount of time to complete this thing. Waiting for
possible suggestions for solvation of this problem

Jun 6 '06 #1
4 8075
Dymus wrote:
problem with deleting big sized hash_map.
have defined a comporator, where defined min_bucket_size (for speed
improvement, since i know that i need to store big ammount of data
(~1Mln)), everything seems to be good, working fast, but problems start
when try to .clear() or delete that hash_map... I think that it just
take ennormous amount of time to complete this thing. Waiting for
possible suggestions for solvation of this problem


Define "enormous amount of time." 2 seconds, 30 minutes, a week? What
happens if you allocate 1 million separate chunks of memory the same
size as one key/value pair in your hash table and then try to delete
them all? Here's a simpler case: How long does the last line of the
following take?

#include <list>

// Substitute your value and key types here
struct MyData { int key; int value[ 3 ]; };

void Foo()
{
std::list< MyData > lst;
for( unsigned i=0; i < 1000000U; ++i )
{
lst.push_back( MyData() );
}

// Swap trick to clear and get rid of capacity, too
std::list<MyDat a>().swap( lst );
}

It might just be that it takes a while to free that much memory when
allocated separately since it is O( N ) to delete.

Cheers! --M

Jun 6 '06 #2
> #include <list>

// Substitute your value and key types here
struct MyData { int key; int value[ 3 ]; };

void Foo()
{
std::list< MyData > lst;
for( unsigned i=0; i < 1000000U; ++i )
{
lst.push_back( MyData() );
}

// Swap trick to clear and get rid of capacity, too
std::list<MyDat a>().swap( lst );
}

It might just be that it takes a while to free that much memory when
allocated separately since it is O( N ) to delete.

Cheers! --M


1: "ennormous time ... I left programm running for more than an hour,
and it still was working, however, there was no endless loop, since it
was stopped during the night (unfortunatelly log of running isn't
availabl, to see how much time it took.
2: this code works good, less than minute to create empty list, and
destroy it later, but does it solve the problem of quick search of
unique keys???
3: big thanks :)

Jun 7 '06 #3
Dymus wrote:
#include <list>

// Substitute your value and key types here
struct MyData { int key; int value[ 3 ]; };

void Foo()
{
std::list< MyData > lst;
for( unsigned i=0; i < 1000000U; ++i )
{
lst.push_back( MyData() );
}

// Swap trick to clear and get rid of capacity, too
std::list<MyDat a>().swap( lst );
}

It might just be that it takes a while to free that much memory when
allocated separately since it is O( N ) to delete.

Cheers! --M


1: "ennormous time ... I left programm running for more than an hour,
and it still was working, however, there was no endless loop, since it
was stopped during the night (unfortunatelly log of running isn't
availabl, to see how much time it took.
2: this code works good, less than minute to create empty list, and
destroy it later, but does it solve the problem of quick search of
unique keys???
3: big thanks :)


1. Well, it sounds like you have other problems, then. Reduce your
program to a *minimal* but *complete* program that demonstrates the
problem, and post it here. I'm guessing that you'll either figure out
the problem while doing that or we'll be able to help you figure it
out.

2. That code was just to test how long it took to free chunks of memory
allocated separately; it does nothing for the quick search problem
(quite the contrary!).

Cheers! --M

Jun 7 '06 #4

Dymus wrote:
problem with deleting big sized hash_map.
have defined a comporator, where defined min_bucket_size (for speed
improvement, since i know that i need to store big ammount of data
(~1Mln)), everything seems to be good, working fast, but problems start
when try to .clear() or delete that hash_map... I think that it just
take ennormous amount of time to complete this thing. Waiting for
possible suggestions for solvation of this problem


possible memory corruption?

I've experienced using gcc: calling pop_back() on an empty vector,
when the vector goes out of scope the destruction takes several seconds
and after this the program continues to run correctly.

Jun 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1508
by: Jacek Generowicz | last post by:
Within our family of projects, we are looking to provide a recommended practice guideline, concerning hashed containers, which would help developers using different compilers, to write portable code. We are primarily interested in gcc 3.2 MSVC++ 6/7.0/7.1 (?) icc gcc 2.95
2
3851
by: Mike Lischke | last post by:
Hi group, Does anybody of you know a template that unites a vector and a hash map? What I'm after is a hash map that can also be accessed by index. I know that an associative container is not laid out like a vector but I could imagine something like double references. That is, first a normal hash map and second a vector for indexed access that references entries in the hash map. Any hint?
9
4187
by: collection60 | last post by:
I've been developing some Unix based shell tools. They work fine on Linux and MacOSX. I want to compile them on Win32. But I can't get hash_map to compile. I tried downloading stl (and stlport) which is supposed to work in MSVC, but it doesn't, it just generates tons of errors for stuff that used to work just fine. Where do I get fts.h to compile and dirent.h compile?
4
1989
by: SebastianBr | last post by:
Dear comunity, my hash map is having to many collision, so I thought to increase the size of the internal index map. How can I do this? Just increasing the functional range of the hash function? I am using a normal stdext::hash_map with long as key and the stdext::hash function of course with long as key. Any ideas, or is the problem to generally described? Cheers mates,
6
6165
by: SimpleCode | last post by:
class COsgCar; class moving_vechicle; hash_map<moving_vechicle*, COsgCar*m_hash; hash_map<moving_vechicle*, COsgCar*>::iterator iter; iter = m_hash.find( pMovingVechicle ); if ( iter != m_hash.end() ) {
2
1860
by: eagerlearner | last post by:
Can anyone check this out, why does this give me the default value of 0 instead of 1 ? Thank you. #include <iostream> #include <hash_map> #include <string> using namespace std; int main() { stdext::hash_map<const char *, int> hm;
1
1777
by: Axel Gallus | last post by:
Hello, i have a question concerning STL non-standard hash_maps under Visual Studio 2005: Microsoft STL requires a "hash_compare" object for hash_maps: template <class Key, class Type, class Traits=hash_compare<Key, less<Key, class Allocator=allocator<pair <const Key, Type > class hash_map
1
475
by: Mirco Wahab | last post by:
Alf P. Steinbach wrote: No, there isn't any (afaik). You can look it up here: http://www.boost.org/doc/libs/1_35_0/doc/html/boost_tr1/unsupported.html#boost_tr1.unsupported.unordered_map Thanks & regards M.
2
8152
by: marek.vondrak | last post by:
Hi, I am wondering if there are any functional differences between SGI's hash_map and tr1's unordered_map. Can these two containers be interchanged? What would it take to switch from hash_map to unordered_map? Thank you. -Marek
0
1214
Jacky Luk
by: Jacky Luk | last post by:
Could anyone explain why this code doesn't crash, http://www.codeguru.com/forum/showthread.php?t=315286 while mine does, typedef stdext::hash_map<int, bool> pf_type; pf_type pf; cAStar::cAStar()
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.