Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
In an Angular 8 SSR app, there is a memory leak

I have an angular SSR app that causes memory leaks on the server

it keeps on increasing memory on the server when the application is used and opened by many users.Unsubscribing subscriptions on ngOnDestroy doesn't work, still memory leaks persist

Not able to find whats the issue and whats the correct way to solve the problem

I am attaching the server.ts code

import "zone.js/dist/zone-node";

import * as express from "express";

import { join } from "path";

const domino = require("domino");
const fs = require("fs");
const path = require("path");

const app = express();

const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(process.cwd(), "dist/browser");

const template = fs
  .readFileSync(path.join(DIST_FOLDER, "index.html"))
  .toString();
const win = domino.createWindow(template);

(global as any)["window"] = win;
(global as any)["KeyboardEvent"] = win.KeyboardEvent;
(global as any)["HTMLInputElement"] = win.HTMLInputElement;
(global as any)["MouseEvent"] = win.MouseEvent;
(global as any)["Event"] = win.Event;
(global as any)["document"] = win.document;
(global as any)["navigator"] = win.navigator;
(global as any)["FormData"] = win.FormData;
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {
  AppServerModuleNgFactory,
  LAZY_MODULE_MAP,
  ngExpressEngine,
  provideModuleMap,
} = require("./dist/server/main");

app.engine(
  "html",
  ngExpressEngine({
    bootstrap: AppServerModuleNgFactory,
    providers: [provideModuleMap(LAZY_MODULE_MAP)],
  })
);

app.set("view engine", "html");
app.set("views", DIST_FOLDER);

app.get(
  "*.*",
  express.static(DIST_FOLDER, {
    maxAge: "1y",
  })
);

app.get(/.*aspx$/, function (req, res) {
  res.redirect(301, "WEBSITE URL");
});

// All regular routes use the Universal engine
app.get("*", (req, res, next) => {
  // special for robots.txt
  if (req.url === "/robots.txt") {
    next();
    return;
  }

  res.render("index", { req });
});

app.listen(PORT, () => {
  console.log(`Node Express server listening on http://localhost:${PORT}`);
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda