troydhanson / uthash

C macros for hash tables and more
Other
4.09k stars 917 forks source link

Maximum no of elements that can be stored #19

Closed saroj13278 closed 10 years ago

saroj13278 commented 10 years ago

Hi, Am using the uthash. Wanted to know what is the maximum number of items that can be added to uthash. The structure am using as struct my_struct { int id; /* key */ emp_data_t emp_data; //a structure of 920 bytes of memory UT_hash_handle hh;
};

When am adding it goes around 42630 records ( am starting the id from 1 ) then the memory allocation fails .Is there any way to overcome from it.

troydhanson commented 10 years ago

On Jan 3, 2014, at 6:52 AM, saroj13278 notifications@github.com wrote:

Hi, Am using the uthash. Wanted to know what is the maximum number of items that can be added to uthash. The structure am using as struct my_struct { int id; /* key */ emp_data_t emp_data; //a structure of 920 bytes of memory UT_hash_handle hh;

};

When am adding it goes around 42630 records ( am starting the id from 1 ) then the memory allocation fails .Is there any way to overcome from it.

There is no hard coded maximum. There are a few possibilities to check. First, your keys are all unique right? (You said they start at 1, and you increment each one right?) I also recommend checking the hash distribution. You can use hashscan or keystats as described in the user guide. That can tell you if another one of the built-in hash functions would distribute your keys better. That prevents the hash table from expanding too much. Most likely something else is going on. I have put millions of entries into hash tables with no trouble. I would check the program by running it under valgrind. Also build it with -DHASH_DEBUG=1 and run it once to ensure there is no corruption. Those are just some ideas to get you started.

Troy

troydhanson commented 10 years ago

Please use the Google group if you wish to discuss further.