Log in

View Full Version : Quests...Memory Hog?


krich
06-11-2003, 11:55 AM
I just realized just how much memory Quests take up...

They use about 465k (not counting the linked list overhead) per NPCType that has a quest file and if there is a "default" quest file, then it's 465k for EVERY NPCType! That would hurt my poor 128Mb server were I to put in all the quests published in the Quest forum.

The struct is as follows:


struct Events {
int index;
int npcid;
char event[100][100];
int line[65535];
char command[100][2048];
};

One could save memory by converting the event and command definitions into linked lists themselves, as such:


struct EventList {
char event[100]
char command[2048]
}

struct Events {
int npcid;
int line[65535]; //Anyone know what this is for?
MyList <EventList> MyEvents;
};

Or something like that... Thus reducing the memory footprint by only using memory when there is something to actually remember. The hard part is that this would require an overhaul of the quest code to use the new structs.

Comments, Ideas, Complaints? :wink:

Regards,

krich

Trumpcard
06-11-2003, 07:12 PM
Thats probably a great idea... 465k per quest????

Zern
06-11-2003, 09:11 PM
Ouch .... would definitly say a good touch up is needed.

krich
06-12-2003, 07:11 AM
Alright...here's what I'm thinking of doing...hopefully its not over my head
(Keep in mind I'm slow and doing this in free time)

1) Document the grammar/intent of Wes' Quest Script Language (underway now)
2) Code up a parser to tokenize and grammar check the input files
3) Insert the new structures along side the existing until the new stuff works
4) Modify parser.cpp to use the new structures
5) Hopefully keep all functionality that existed before I started

Regards,

krich

krich
06-12-2003, 07:18 AM
Thats probably a great idea... 465k per quest????

Yeah...no kidding. I noticed this when, on a whim to learn the new quest system, I decided to create a series of quest scripts for the first Ranger Epic. Zone was truncating my quest scripts because they were too long, so I went into the code to bump up the buffer for events and :shock: !!

I'll get it fixed...maybe...

Regards,

krich

krich
06-21-2003, 08:00 AM
MEMORY HOG UPDATE:

Alright folks, I'm about to finish up coding the changes to the data structures that handle the quests. I have made some wholesale changes to many parts of parser.cpp and parser.h. I'd like for someone to assist me in verifying this code before I get Trumpcard to look at it. PM me on #eqemu if interested (Nick = krich or Wany) My server is Ken's (Under Test) Linux Server.

The end result is as follows:

Old Code Results
Zone: freportw
Quest memory footprint*: ~8,500,000 bytes :shock:

New Code Results
Zone: freportw
Quest memory footprint*: ~291,000 bytes :mrgreen:

* Doesn't include overhead for Kaiyodo's linked list class

I'd say that's almost a 30 fold improvement in memory utilization. :shock: (as my 128Mb Linux server emits a sigh of relief...)

BTW, I decided to back off on the parser work...will take too much time. I'll just keep patching the existing code for now.

Regards,

krich