Optimizing Your DXL Code
In DXL development, performance and stability depned alot on how you manage memory. Because DXL does not provide automatic garbage collection, failing to explicitly deallocate data structures can lead to “System memory exhausted” errors and slow response times.
1. The String Trap #
Strings in DXL persist in memory and are not deallocated until DOORS is closed.
While they are easy to use, they can “pollute” the string table during intensive processing.
Optimization Tip #
- Minimize string concatenation in loops.
- For heavy text manipulation, always use Buffers instead.
2. Text Buffers: The Scalable Choice #
Buffers are a speed and memory-efficient way to manipulate text, especially for parsers and importers.
Unlike strings, they have no intrinsic size limit and can grow as needed.
Best Task Type #
- Large-scale text processing
- Building complex output
Deallocation #
delete(Buffer &b)
This command deletes the buffer and sets the variable to null.
3. Skip Lists: Dictionaries and Structs #
Skip Lists are efficient, dictionary-like data structures used for fast lookups.
Since DXL does not support user-defined struct objects, many developers use Skip Lists to build complex data hierarchies.
Best Task Type #
- Storing mappings (e.g., Absolute Numbers to Object handles)
- Creating arbitrarily nested data
Deallocation #
delete(Skip s)
s = null
Important Note #
delete(Skip s) does not automatically set the variable to null.
You should manually set it to null after deletion to prevent runtime errors.
4. Dynamic Arrays: 2D Grid Data #
The Array type provides a dynamically sized two-dimensional grid.
If you assign a value outside its initial bounds, it automatically resizes itself.
Best Task Type #
- Tabular data processing
- Grid-based output generation
Deallocation #
delete(Array a)
5. Specialized Task Types #
Different tasks require specific structures that also need careful cleanup.
| Task Type | Data Structure | Deallocation Command |
|---|---|---|
| Pattern Matching | Regexp | delete(Regexp) |
| Module Metadata | ModuleProperties | delete(ModuleProperties&) |
| Database Locks | LockList | delete(LockList list) |
| Automation | OleAutoArgs | delete(OleAutoArgs autoArgs) |
| Module Partitions | PartitionDefinition | dispose(PartitionDefinition pd) |
| User Discussions | Comment or Discussion | dispose({Discussion& d|Comment& c}) |
Summary Checklist for Optimized DXL
Use Buffers for Strings
- Avoid heavy string operations
- Use
Bufferand delete it afterward
Explicit Cleanup
- Always call the specific
deleteordisposefunction for every structure you create
- Always call the specific
Set to Null
- For Skip Lists and other handles, manually set the variable to
nullafter deletion
- For Skip Lists and other handles, manually set the variable to
Monitor Usage
- For long-running scripts, use:
getMemoryUsage()
to track the impact of your data structures on the DOORS client.