Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7651513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:31:35+00:00 2026-05-31T11:31:35+00:00

I have written a program in Javascript which reads numbers from a file ,sorts

  • 0

I have written a program in Javascript which reads numbers from a file ,sorts them and then writes them back to the file.But I not able able to find a suitable method or tool to get the memory usage of the program.(something like Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory(); in java).If someone could please give me a lead I would be thankful.

Here is the code.

<html>
<script>
var oRequest;

var data=new Array();
var b= new Array();
var j
var k;
var temp;
var temp1;

if(document.all) {

oRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
else {

oRequest = new XMLHttpRequest();
}


oRequest.open("GET", "file:///C:/numbers.txt", true);
oRequest.send(null);


numbers= oRequest.responseText.split("\n");
for (var i = 0;i<(numbers.length-1);i++)
{
numbers[i] = parseInt(numbers[i],10);
}

var d = new Date();
var start = d.getTime();

for(var i=0;i<numbers.length;i++)
{
for(j=0;j<(numbers.length-1);j++)
{
 if(numbers[j]>numbers[j+1])
{
 temp=numbers[j+1];
  numbers[j+1] = numbers[j];
  numbers[j] = temp;
 }
 }}

var g = new Date();
var end =g.getTime();
var diff=(end-start);


</script>
<script>
function WriteFile() 
{
var fso  = new ActiveXObject("Scripting.FileSystemObject"); 
var fh = fso.CreateTextFile("C:\\BubbleJS.txt", true); 
for(i=0;i<5000;i++)
{
fh.WriteLine(numbers[i]);
}   
fh.WriteLine("\n");
fh.WriteLine("The time required for sorting is "+diff+" Milliseconds");
fh.Close(); 
}
 </script>


<form>
<body background="Bubble.png">
 <h1>&nbsp;</h1>
 <input type="button" onClick='alert("Directing to Home Page"); window.location = "Home           Page.html"' value="Back to Home  Page">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="button" onClick=WriteFile(); value="Begin Sorting!" 
    style="width: 174px; margin-left: 0px">&nbsp;&nbsp;

   </form>

   </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:31:36+00:00Added an answer on May 31, 2026 at 11:31 am

    The JavaScript language and core libraries do not provide a way to view or calculate the memory usage of the runtime.

    Your only hope is to find a library (e.g. ActiveX plugin, etc.) which can do it for you. Note that the developer tools of some popular web browsers (Chrome, Firefox, possibly others) provide a memory profiling graphical interface, so perhaps there are programmatic hooks you can find; however, if they exist they almost definitely won’t work cross-browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program which reads input from csv file and its working
I have written this program, which sorts some ints using a functor: #include<iostream> #include<list>
I have written a program which uses a SQL exception class and then use
I have written a program that reads in a File object (really an XML
I have written a program in C to parse large XML files and then
i have written a snake program using javascript.. the problem is that the snake
I have written a program which uses CardLayout. I want it to show a
I have written sample program which uses XSLT to generate HTML response. Check below
I have written a program to insert a row in the contact database which
I have written a program in clojure but some of the functions have no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.