Chinese (Simplified)EnglishFrenchItalianPortugueseSpanish

Ocean Optics
Worldwide Headquarters
Largo, Florida, USA

+1 727-733-2447

[email protected]

Sales, Service
& Support Facility
Duiven, The Netherlands

+31 26-319-0500
+33 442-386-588

[email protected]

Ocean Optics GmbH Sales,
Service & Support Facility
Ostfildern, Germany

+49 711-34-16-96-0

[email protected]

Sales Support
for the
United Kingdom

+44 1865-819922

[email protected]

Sales, Service
& Support Facilities
Shanghai, PRC – Beijing, PRC

+86 21-6295-6600

[email protected]

Home > Frequently Asked Questions > Software > OmniDriver and SPAM > OmniDriver Memory Management in Delphi

OmniDriver Memory Management in Delphi

Our general-purpose OmniDriver device driver allows you to control spectrometers and collect spectra using Delphi, the popular Object-Pascal system from Embarcadero (formerly Borland).

Some customers have noted that memory usage seems to climb when calling Delphi from OmniDriver, which can raise fears of a potential memory leak.  The solution is to make sure you call SafeArrayDestroy on every PSafeArray as soon as you are finished processing the result — and definitely before you try reusing the same object.

This will ensure Delphi “marks” the memory in our .NET driver as free to be released.  Note that the memory won’t be immediately released — .NET has its own internal schedule for reclaiming marked memory, and it will collectively release all marked segments at the next scheduled interval.

If you monitor this sequence in a process manager, you should see that memory size climbs over time as you continue to take acquisitions, and then will sharply drop as GC kicks in; this cycle will repeat over the runtime of your application, creating a “sawtooth” pattern.  This is correct and normal, and indicative that everything is working as expected.

  • Was this answer helpful?
  • Yes   No


Cross-Platform Full-Featured Device Driver