Questions on OOP in MQL5 - page 10

 
Vasiliy Sokolov:

...Which variant is used in MQL is unknown...

There is no rubbish collector in MQL.
 
Vasiliy Sokolov:

Good afternoon. Computer memory has the same performance regardless of whether it is used in a stack or heap context. Dynamic memory management itself depends on rubbish collector implementation: for example, it can be reference counting as in Python (slower version) or analysis of object generation epochs with execution graph traversal in background process (Net CLR). Which variant is used in MQL is unknown, but we can assume that it is extremely efficient, because the user of MQL5 has the delete operator directly available, which greatly simplifies the work of GC itself. Therefore, your concerns about overhead when using new are groundless - feel free to use dynamic memory.

As for "stack overflow", the only way you may encounter this case in modern systems is when using complex recursion or making a mistake in the recursive algorithm. A modern program always works in OC protected mode in virtual address space, with dynamic loading of memory pages, so do not worry: the stack will not overflow:)

False statement.

 
Dmitry Fedoseev:
There is no rubbish collector in MKL.

where is the information from? what is MT4 / MT5 written on? - any information?

;)

ZS: the maximum that is freely available is a vacancy from Metakvot, there are written requirements for programmers to applicants ;)

 
Igor Makanu:

where is the information from? what is MT4 / MT5 written on? - any information?

;)

ZS: the maximum that is freely available - job vacancies from Metakvot, there are written requirements for programmers to applicants ;)

What difference does it make what it is written in? In mql, objects created with new are not deleted by themselves. By the way, neither in c++))

 
Dmitry Fedoseev:
There is no rubbish collector in MKL.

Dimitri, you're wrong. Here are three reasons why MetaTrader has a rubbish collector after all:

  1. MQL5 automatically deletes objects created without new. Pointers to such objects have type AUTOMATIC. They can be deleted automatically either by the Holy Spirit, or by the rubbish collector.
  2. More than once the developers have mentioned that MQL5 program is executed by MetaTrader internal virtual machine. If there is a virtual machine, then there must also be the rubbish collector.
  3. If a dynamic object has not been deleted as required by user, MetaTrader will indicate it with 'leaked memmory' message indicating how many and which objects have not been deleted. That is, MetaTrader knows in fact how much and what has been allocated - i.e. it is obvious that there is some system running in parallel which controls the memory operation, this is the rubbish collector.
 
Dmitry Fedoseev:

False statement.

P.S. You've changed a lot over the years, though. You've become a bit spiteful. I remember you used to offer a lot of constructive suggestions. Now you're constantly bickering: meaningless arguments / denials / denunciations. What's it all for? You want to hit me harder? - I'll give you a stone myself: hit me anyway you want, but I feel sorry for you all the same.

 
Vasiliy Sokolov:

Dimitri, you're wrong. Here are three reasons why MetaTrader has a rubbish collector after all:

  1. MQL5 automatically deletes objects created without new. Pointers to such objects have type AUTOMATIC. They can be deleted automatically either by the Holy Spirit, or by the rubbish collector.
  2. More than once the developers have mentioned that MQL5 program is executed by MetaTrader internal virtual machine. If there is a virtual machine, then there must also be the rubbish collector.
  3. If a dynamic object has not been deleted as required by user, MetaTrader will indicate it with 'leaked memmory' message indicating how many and which objects have not been deleted. So MetaTrader knows exactly how much and what has been allocated - it's obvious that there is some system running in parallel which controls the memory handling, this is a rubbish collector.

1. not the holy spirit and not the rubbish collector.

2.3 You can fantasise endlessly.

 
Vasiliy Sokolov:

Z.I. You've changed a lot over the years. You've become a bit embittered. I remember you used to offer a lot of constructive suggestions. Now you're constantly bickering: just senseless arguments / denials / denunciations. What's it all for? You want to hit me harder? - I'll give you a stone myself: hit me anyway you want, but I feel sorry for you anyway.

Sobbing!

 
Dmitry Fedoseev:

1. neither a holy spirit nor a rubbish collector.

2.3 The imagination is endless.

Let's read the docs. The new operator does not return a pointer to an object, but an object descriptor. I dare to suggest that any class is wrapped in some wrapper that safely kills the forgotten object when minimizing the program and at the same time kindly indicates presence of leaks. In general, this mechanism would be best left to the creators to comment on.
 
Vladimir Simakov:
Let's read the docs. The new operator does not return a pointer to an object, but an object descriptor. I dare to suggest that any class is wrapped in some wrapper that safely kills the forgotten object on minimization, at the same time kindly pointing to existing leaks. In general, this mechanism would be best left to the creators to comment on.

Yeah, it deletes and writes a message about memory leaks, just so that the programmers who write EAs don't get bored with their lives.

It's interesting how yesterday there was a memory leak and today there can't even be one.

And speaking of birds... descriptors are also pointers. And you know, the word itself doesn't change anything, whether it's a descriptor, a pointer, an identifier.

Reason: