Subject | Re[2]: [Firebird-Java] Possible memory leak in EncodingFactory ? |
---|---|
Author | Alexey Panchenko |
Post date | 2006-06-21T03:58:31Z |
Roman Rokytskyy wrote:
Or it should be cached at all - what is the role of charMapping
argument - should it be include in cache key ?
- first is "new char[]"
- second is during "new String" - the char[] is copied into the String
Without pooling the shared char[] is used and only new String is
allocated.
Probably we can use the String constructor:
public String(byte bytes[], int offset, int length, String charsetName)
Though it can be slower than internal implementation.
--
Best regards,
Alexey mailto:alex+news@...
>> if (USE_ENCODING_CACHING) {Shouldn't it be "translatorCache.put(encoding, result);" ?
>> Encoding result = (Encoding)translatorCache.get(encoding);
>>
>> if (result == null) {
>> result = getEncodingInternal(encoding, charMapping);
>> translatorCache.put(encoding, charMapping);
>> }
Or it should be cached at all - what is the role of charMapping
argument - should it be include in cache key ?
>> if (EncodingFactory.USE_ENCODING_CACHING) {The reason of slowdown is double memory allocations above:
>> char[] bufferC = new char[in.length];
>> int length = decodeFromCharset(in, 0, in.length, bufferC);
>> return new String(bufferC, 0, length);
- first is "new char[]"
- second is during "new String" - the char[] is copied into the String
Without pooling the shared char[] is used and only new String is
allocated.
Probably we can use the String constructor:
public String(byte bytes[], int offset, int length, String charsetName)
Though it can be slower than internal implementation.
--
Best regards,
Alexey mailto:alex+news@...