- Dart:Scalable Application Development
- Davy Mitchell Sergey Akopkokhyants Ivo Balbaert
- 225字
- 2025-04-04 19:07:42
Observing the Dart VM internals
If you have been watching the output window keenly as you have launched Dart projects, you will have noticed references to the Observatory. This tool (which is part of the Dart SDK) allows developers to look inside a running Dart virtual machine, and profile the ongoing activities. This is useful to find out exactly what an application is doing and where bottlenecks exist.

The Observatory supports command line applications and web applications (Dart versions and not the compiled to JavaScript output) running in Dartium. To enable it, simply pass one of the many Observatory command line parameters—see the SDK documents (https://www.dartlang.org/tools/dart-vm/) for a full listing:
dart --enable-vm-service bin/main.dart
Launch the main.dart
program with the Observatory attached, and browse to the address localhost:8181
(note that this port number can change though it can be specified in the launch command parameter --enable-vm-service=<port>/<IP address>
):
chromium.exe index.html
Launch index.html
with the Observatory attached. The address to put into the web browser will be shown:
Observatory listening on http://127.0.0.1:34935
The URLs can be opened in any web browser, the most important feature is the Refresh button, that appears and re-samples the data that is being displayed.
While you are waiting for the data monitor to collect data, take some time to explore the inner workings of the Dart VM as it runs the code.