[Mono-devel-list] Why not to use gettext ()
kornelpal at hotmail.com
Fri Jun 17 03:41:31 EDT 2005
> From: Ben Maurer
> On Fri, 2005-06-17 at 00:29 +0200, Andreas Nahr wrote:
>> ResourceManager would need to construct a hashtable using more that
>> function calls (resulting in a high number of million or even billion
>> operations) consuming about 1-2MB of ADDITIONAL RAM (additional to the
>> strings, assuming identifier length of 10-20 chars). This would be
>> ram, so the GC would need to run several times to bring that all up to
>> Gettext would be even worse (if using hash-lookup), but shines when not
>> translated (will the exceptions get translated anyways?)
> Any solution that actually loads everything into memory at startup is
> horrible. We need a solution that uses memory mappable files.
I think the only impact of localization can be memory usage. I am not afraid
of CPU usage because usually it does only lookup and GetText is rarely
called. I think throwing an Exeption, then catching it and running
finalyzers needs much more CPU time than looking up the message and we never
wanted to drop exception handling.
By the way if you worry about memory usage a custom ResourceSet
implementation that has no Hashtable but looks up string resource every time
they are requested can be implemented.
In fact ResouceManager of MS.NET uses an internal ResourceSet implementation
that loads each resource only when needed. Note that it saves them in a
Hashtable to make next load faster but if we want to we don't have to do the
same. (I obtained these informations just using reflection on the
ResourceSet returned by ResourceManager.GetResourceSet).
More information about the Mono-devel-list