Thread: Memory issue
View Single Post
  #6  
Old 09-08-2006, 11:56 PM
eq4me
Hill Giant
 
Join Date: Jul 2006
Posts: 166
Default

Please bear with me if the below is a bit vague and filled with lots of assumptions. I am occupied with other stuff right now and I am just feeling my way back in C programming after 8 years of doing other things.
My assumption is that right now the size of the shared memory is set by the number of table entrys. That means even if 90% of the table entrys are empty it will still be reserved in memory.
There could be multiple ways to redeem that.

First you could use the c++ function map(), according to a C++ crack I know that might be not a good idea to do in a shared memory segment.

Here a small scrap of code :
Code:
#include <map>

main()
{
    typedef map<int, double> id_map;
    id_map foo;

    foo[17] = 3.5;

    foo[19] = 7;

    ++foo[17];


    for (id_map::iterator i = foo.begin(); i != foo.end(); ++i
    {
        int idx = i->first;
        double val = i->second;
    }

    id_map::iterator i = foo.find(5);
    if (i != foo.end())
        foo.erase(i)
}
The second possiblity could be to do a double pointer. For each table entry generate a pointer that points to the actual data entry. On default this is set to void. So only if the mysql table entry holds data you need to allocate memory. (Sorry for being very vage here but our resident C expert didnt had much time and just outlined it briefly - to brief for me to understand propperly. )


The third possibility would be to allow multipe tables.

Lets take the items table for an example.

items (the one we have right now = default, so its either peq or cavedudes db)
items.ax (angelox db additions)
items.custom (local customized stuff)

The big advantage would be that these tables can grow without interfering with each other.
The problem here would be how to allow eg. the items.ax table to override stuff in the items table. Maybe an additional table entry which holds the id number and table name for the entry you want to override would do the trick.

like

Code:
CREATE TABLE items.ax (
  id int(11) NOT NULL default '0',
  overridetable  varchar(64) NOT NULL default '',
  overrideid int(11) NOT NULL default '0',
  overrideprority int(11) NOT NULL default '0',
The field overridepriority would eg. allow for local customizations that build on more than one table.

Well, enough of my ramblings. Maybe someone with more knowledge about the inner workings of EQEmu can comment on this.
Reply With Quote