gc.html 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <!doctype html>
  2. <title>Test that emulator is GCed properly</title>
  3. <script src="../../build/libv86.js"></script>
  4. <script>
  5. "use strict";
  6. window.onload = function()
  7. {
  8. var emulator = new V86({
  9. wasm_path: "../../build/v86.wasm",
  10. memory_size: 32 * 1024 * 1024,
  11. vga_memory_size: 2 * 1024 * 1024,
  12. screen_container: document.getElementById("screen_container"),
  13. bios: { url: "../../bios/seabios.bin" },
  14. vga_bios: { url: "../../bios/vgabios.bin" },
  15. cdrom: { url: "../../images/linux.iso" },
  16. autostart: true,
  17. });
  18. setTimeout(() => {
  19. emulator.stop();
  20. emulator.destroy();
  21. console.log("Emulator freed. Check using devtools (in chromium: Memory -> Heap Snapshot -> click collect garbage -> take snapshot).");
  22. }, 3 * 1000);
  23. }
  24. </script>
  25. <!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
  26. <div id="screen_container">
  27. <div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
  28. <canvas style="display: none"></canvas>
  29. </div>