Any way to interpret javascript functions?

  • Thread starter Thread starter mdb
  • Start date Start date
M

mdb

I have an application with a windows form that I am currently embedding an
AxWebBrowser object on so that I can have it navigate to a web page. This
web page contains simple javascript code which takes two parameters that I
pass to it via the URL, and opens a new window with varying characteristics
(eg size, toolbar visibility, etc) depending on the data that I pass it.

However, the AxWebBrowser places an enormous load on the memory - its
footprint runs about 8Meg I think. I'd like to be able to just read the
javascript that is returned by the (ASP) web page and let it do its thing
directly.

Any suggestions on how I can parse the javascript to allow it to work
without having to write a javascript parser? Alternatively, any better way
to include a slimmed-down browser??

Thanks!

-mdb
 
mdb said:
I have an application with a windows form that I am currently embedding an
AxWebBrowser object on so that I can have it navigate to a web page. This
web page contains simple javascript code which takes two parameters that I
pass to it via the URL, and opens a new window with varying
characteristics
(eg size, toolbar visibility, etc) depending on the data that I pass it.

However, the AxWebBrowser places an enormous load on the memory - its
footprint runs about 8Meg I think. I'd like to be able to just read the
javascript that is returned by the (ASP) web page and let it do its thing
directly.

Any suggestions on how I can parse the javascript to allow it to work
without having to write a javascript parser? Alternatively, any better
way
to include a slimmed-down browser??

You need to do more than parse JavaScript - you need to interpret it. It's
an entire computer language, you know...

Also, I'm curious to know how you measured the footprint of AxWebBrowser.
Also, even granted it might be 8Mb, exactly what problem does an 8Mb
footprint cause in your application? Excessive paging?

John Saunders
 
You need to do more than parse JavaScript - you need to interpret it.
It's an entire computer language, you know...

Also, I'm curious to know how you measured the footprint of
AxWebBrowser. Also, even granted it might be 8Mb, exactly what problem
does an 8Mb footprint cause in your application? Excessive paging?

Ok well I admit that its probably not the most accurate or "real" way to
measure the memory footprint, but its what users will see. When I run my
application without creating the AxWebBrowser, Task Manager shows about 8M
less memory being used than when I run it and I do create it. And its not
so much that it creates a problem, but this is supposed to be a fairly
"lightweight" application. I recall reading messages that the memory
reported by Task Manager isn't a good way to determine memory usage (I
guess due to shared DLLs and such) but again, its what the average user is
going to use and see.

Regarding the interpreting of JS - yes... that's what I meant. :)

-mdb
 
mdb said:
Ok well I admit that its probably not the most accurate or "real" way to
measure the memory footprint, but its what users will see. When I run my
application without creating the AxWebBrowser, Task Manager shows about 8M
less memory being used than when I run it and I do create it. And its not
so much that it creates a problem, but this is supposed to be a fairly
"lightweight" application. I recall reading messages that the memory
reported by Task Manager isn't a good way to determine memory usage (I
guess due to shared DLLs and such) but again, its what the average user is
going to use and see.

A quiet few words about memory:

Memory is cheap these days. Memory is also virtual these days. What Task
Manager is showing you is the number of virtual memory pages allocated to
the process, and the number of physical memory pages currently used by the
process. The Virtual number is only a measure of what physical memory would
be used if every virtual page were brought into memory at once. The Physical
memory number is only a measure of the number of pages in memory at a given
instant.

Measures over time are more useful, and more closely reflect what users will
see. As an example, it's possible that 2Mb of that virtual memory footprint
represents code to handle things like .PNG images, or something else your
users will never use. Those pages will never be brought into memory.

This means that the "8Mb footprint" is something that users will never see -
unless they look in Task Manager.

John Saunders
 
Hi mdb

You can use JavaScript in .NET - JScript.NET. And one of the most useful
functions is eval(String) which can interpret a string of script and return
the result of the evaluation. If you use the JSc.exe command line compiler,
then you can create a .dll that can be used from any .NET language that
includes support for dynamic evaluation of JavaScript - it's pretty cool.

So if you just want dynamic evaluation of JavaScript, then you don't need
the Web browser control...however, you memory footprint for a .NET exe is
also pretty big, and memory is cheap...

HTH

Nigel Armstrong
 
Back
Top