ASP components aren’t released by setting their references to Nothing

ASP components aren’t released by setting their references to Nothing

If you instantiate an ActiveX component from an ASP script under IIS 4 and previous versions, using the Server.CreateObject command, you might believe that the object is deallocated as soon as you set its reference to Nothing – this is how all COM components work, right?

The problem with ASP components is that IIS keeps a private reference to the objects you instantiate from ASP scripts, and this reference is set to Nothing only after the entire ASP script has completed its execution. This extra reference is necessary to invoke the OnEndPage method when the ASP script has completed its execution.

In most cases this detail doesn’t cause any problem, but sometimes it can be the source of very subtle bugs. For example, if your component contains some code in the Class_Terminate event, this code will be executed at the wrong moment. For example, if the code read a Session or Application variable, it can retrreive the wrong values. Worse, if the code sends HTML output through the Response ASP object, it won’t work at all, because when the Class_Terminate event fires, the page has already been sent to the client browser.

Note that IIS5 deals with COM components in a smarter way: if the component doesn’t expose an OnEndPage, when the ASP script sets the last reference to it is to Nothing the object is immediately destroyed.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as