proper use of ini-files
-
Hi, almost every one of my programs uses an ini-file. I have written a class that scans the file at program start and stores all variables in a global dynamically allocated struct. Because this takes some memory when the program gets larger, I was wondering if scanning the file for a particular entry when it is actually needed wouldn't be the better alternative. What is the 'proper' way to use ini-files and why? -Sebastian
While the discussion on reading ini at startup versus on-demand would be interesting, I think you should ask yourself if it's worth the trouble. How much memory are you using for this global struct? Tomasz Sowinski -- http://www.shooltz.com
-
While the discussion on reading ini at startup versus on-demand would be interesting, I think you should ask yourself if it's worth the trouble. How much memory are you using for this global struct? Tomasz Sowinski -- http://www.shooltz.com
Hi, its not very much for a smaller program, but I was wondering if I should really store every minor option like background colors, switches for controls or windows the whole time the program is running. Thanks for your time. -Sebastian
-
Hi, its not very much for a smaller program, but I was wondering if I should really store every minor option like background colors, switches for controls or windows the whole time the program is running. Thanks for your time. -Sebastian
Assume that it's biggest program you're ever going to write. Multiply the struct size by 4. How much memory are you going to allocate? Tomasz Sowinski -- http://www.shooltz.com
-
Assume that it's biggest program you're ever going to write. Multiply the struct size by 4. How much memory are you going to allocate? Tomasz Sowinski -- http://www.shooltz.com
OK, you're right, it won't use up all my RAM. But is it really good programming practice to have all these unused variables lying around all the time? -Sebastian
-
OK, you're right, it won't use up all my RAM. But is it really good programming practice to have all these unused variables lying around all the time? -Sebastian
Good programming practice is to spend your development time on issues that really matter. I don't believe that loading ini settings at startup can hurt you or your performance. If it works for you, leave it, unless you have nothing else to do (in this case, it's better idea to go for some beer). Tomasz Sowinski -- http://www.shooltz.com
-
Hi, almost every one of my programs uses an ini-file. I have written a class that scans the file at program start and stores all variables in a global dynamically allocated struct. Because this takes some memory when the program gets larger, I was wondering if scanning the file for a particular entry when it is actually needed wouldn't be the better alternative. What is the 'proper' way to use ini-files and why? -Sebastian
It's simply a matter of what is prudent within the context of the program's architecture. I think almost all of my programs do it that way (loading the ini data into a struct or object). There is no "proper" way to do it really beyond obeying the laws of C++ physics. :-)
-
It's simply a matter of what is prudent within the context of the program's architecture. I think almost all of my programs do it that way (loading the ini data into a struct or object). There is no "proper" way to do it really beyond obeying the laws of C++ physics. :-)
I though ini files where long since dead ... I put everything in the registry these days.... Regards Ray "Je Suis Mort De Rire"
-
I though ini files where long since dead ... I put everything in the registry these days.... Regards Ray "Je Suis Mort De Rire"
Ray, You've just started a flamewar... Cheers, Tomasz Sowinski -- http://www.shooltz.com
-
I though ini files where long since dead ... I put everything in the registry these days.... Regards Ray "Je Suis Mort De Rire"
I don't use the registry unless it makes sense to do so. The more data tha's contained in the registry, the longer it takes Windows to load. COM forces registry use, so if a program uses COM, there's no reason not to contribute to the registry bloat, but for simple programs, why bother? INI files are alive and well - long live INI files. :-)
-
Ray, You've just started a flamewar... Cheers, Tomasz Sowinski -- http://www.shooltz.com