i am using Next.js version 8.0.4.
the problem i'm facing is that when i first build the app and start it is taking almost 150 Mb memory on server but it grows gradually over time and it becomes very big in just 3 or 4 days depending on how many users are visiting my website.
i have searched a lot about memory leaks and i don't think that i have done anything in my code that can cause a memory leak.
i also have noticed that this growth in using memory is happening whenever i refresh the page or when i load it for the first time, in fact when the page is rendering on the server side. with every refresh i'm seeing that memory goes up for 1-2 Mb and it won't be released
but when i am on the client side and i route to other pages on client side everything is fine.
i don't know what can cause this. i would appreciate it if someone could help me solve this problem.
https://i.stack.imgur.com/t4VDm.jpg
this is also my next.config.js if it helps:
module.exports = withCss({
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: "[local]___[hash:base64:5]",
},
webpack(config, {dev, isServer}) {
if (ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8080 : 4000,
openAnalyzer: true
}))
}
config.plugins.push(new CompressionPlugin({
filename: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8,
cache: true,
compressionOptions: {level: 1}
}));
config.optimization.minimizer = [new UglifyJsPlugin({
test: /\.js(\?.*)?$/i,
cache: true,
parallel: true,
sourceMap: true,
extractComments: 'all',
uglifyOptions: {
warnings: false,
parse: {},
compress: {},
mangle: true,
output: null,
toplevel: false,
nameCache: null,
ie8: false,
keep_fnames: false,
}
})];
config.module.rules.push({
test: /\.(svg|eot|otf|ttf|woff|woff2)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
publicPath: './assets/fonts',
outputPath: 'static/fonts',
name: '[name].[ext]'
}
}
});
if (Array.isArray(config.optimization.minimizer)) {
config.optimization.minimizer.push(new OptimizeCSSAssetsPlugin({}));
}
if (!isServer && !dev) {
config.optimization.splitChunks.cacheGroups.commons.minChunks = 2
}
return config
},
});