-
-
Notifications
You must be signed in to change notification settings - Fork 684
Closed
Description
🐛 Bug Report
Hello, I noticed Increasing memory.
To Reproduce
import i18next from 'i18next';
i18next.init({
lng: 'cs',
debug: true,
resources: {
cs: {
translation: {
"intlDateTime": "{{- val, datetime}}",
}
}
}
});
setInterval(() => {
for (let i= 0; i< 100_000; i++){
i18next.t('intlDateTime', {val: new Date(), formatParams: { val: {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric' ,
milisecond: 'numeric'
// ,faster: Math.random() // for faster simulation uncomment
}}})
}
}, 1);
// Mock with logging
function createCachedFormatter(fn) {
var cache = {};
return function invokeFormatter(val, lng, options) {
console.log(`count of objects: ${Object.keys(cache).length}`, process.memoryUsage().heapUsed / 1024 / 1024);
var key = lng + JSON.stringify(options);
var formatter = cache[key];
if (!formatter) {
formatter = fn(lng, options);
cache[key] = formatter;
}
return formatter(val);
};
}Your Environment
- runtime version: i.e. node 20.12.1
- i18next version: i.e. 22.5.1
- os: Mac
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels