Growth of a C# List

Started by
25 comments, last by Julian90 17 years, 6 months ago
I think you are better off writing those log entries to a file and write that file to a database when the server goes down for its daily server-save.

I mean a log file can grow realy huge during a single stressful day. If you log that much that it may be a performance issue then keeping it in the working memory is definitely a bad idea.

Imo you would even be better off by inserting it into the database just in time.

Advertisement
Quote:Original post by Arild Fines
Quote:Original post by Thevenin
(though, I have no ideas atm of what shortcuts I'd take).

Exactly.


Oh jeeze... [rolleyes]
Quote:Original post by Thevenin
It's honestly not that hard to write specialized code that will outperform Microsoft's code, so stop it with the belated pessimism.


Or you could just use a Queue when you need a Queue...

Quote:Original post by Anonymous Poster
Imo you would even be better off by inserting it into the database just in time.


Thats definently the most straight-forward approach, however, it will probably be tragic -- as interactions with the MySQL database take quite a toll on the performance of my game, I'm assuming it's because my code is entirely synchronis and that the MySQL Connector is blocking (it would have to be for 'reads' I don't know about 'writes' though).

I'm honestly not too worried about server crashes causing all the chat logs to be erased (if I decide to store it in memory), the server use to crash on an hourly basis back when I had it all written out in Procedural-C, but it doesn't anymore. I'm putting in message logging mostly so that I can handle player harassment claims.
So dump the list periodically, every 10 seconds or something, and clear it.

That way the list will quickly level off to some good size, and neither data loss nor performance should be a major issue.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Thevenin
Quote:MSDN Library
Performance Considerations

In deciding whether to use the List or ArrayList class, both of which have similar functionality, remember that the List class performs better in most cases and is type safe. If a reference type is used for type T of the List class, the behavior of the two classes is identical. However, if a value type is used for type T, you need to consider implementation and boxing issues.
... inaddition, in list theory it seems pretty acceptable to assume that adds can be done in constant time. And subsequently disappointed to find out that adds can now (at apparent randomness) take significant durations of time to complete.
That's because an ArrayList doesn't use generics, so you're forced to manually box and unbox your data types. If you have the option to use generics, then use them.
Rob Loach [Website] [Projects] [Contact]
if you want constant time insertions use LinkedList<T> if you want constant time acces use List<T>.

Seriously i think half of the posts in this thread are due to microsoft choosing poor names for the classes lol.

This topic is closed to new replies.

Advertisement