You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
A canvas is an object to which an array of pixels is bound. The Resource is responsible for binding this array of pixels (see bool CCanvas::Create())
It is bad practice to delete and recreate a canvas all the time.
It is good practice to create a canvas when it is needed and delete it when it is no longer needed, e.g. at the end of the programme.
Once you create a canvass object, you can clean it up, overwrite the pixel array every frame, resize the canvass and move it anywhere you want.
Thanks, it became a little clearer, but not all. Do I understand correctly that if after creating a canvas object, I simply delete the object from the chart using ObjectDelete(), then the pixel array bound to this object remains untouched and... When I create a new canvas object with a different name again, a new pixel array is created in memory, and thus, theoretically, it is possible to fill the whole memory?
Or is the old pixel array simply re-bound to the last created canvas-object each time (because it is and only with it that all functions of the used instance of the canvas-class start working)?
Thanks, it became a little clearer, but not all. Do I understand correctly that if after creating a canvas object, I simply delete the object from the chart using ObjectDelete(), then the pixel array bound to this object remains untouched and.... When I create a new canvas object with a different name again, a new pixel array is created in memory, and thus, theoretically, it is possible to fill up all memory?
Of course, ownerless resources will multiply.
Or still the old pixel array is simply re-bound to the last created kanvas-object every time (because it is and only with it that all functions of the used instance of the kanvas-class start working)
Your imagination is superb. I envy you. I would not have thought of such a thing. :))
However, if you save the name of an ownerless resource, you can re-bind it to a new bitmap object. But this is from the field of schizophrenia.
However, if you save the name of an ownerless resource, you can re-bind it to a new bitmap object. But this is from the field of schizophrenia.
I take that back. I think I found a case where this might be useful.
Thanks, I just wanted to understand what happens in memory if you use ObjectDelete () instead of Destroy (). And I realised that in such a case graphic resources (ownerless pixel arrays and whatever else) will be multiplied if a new name is generated each time for a new canvas object.
And if I use ObjectDelete(), but then create a canvas object with the same name, will the pixel array be old or still new?
p.s. the questions are probably stupid, but I need it to understand the mechanism of canvas
.
Thanks, I just wanted to understand what happens in memory if you use ObjectDelete () instead of Destroy (). And I realised that graphical resources (ownerless pixel arrays and something else) will multiply if a new name is generated for a new canvas object each time.
It's easy to check by writing a simple script.
Can you tell me how?
Can you tell me how?
like this:
and look at the comment:
!!! after running this script, don't forget to reload the terminal to free up memory for orphan resources.
like this:
and look at the comment:
!!! after running this script, don't forget to reload the terminal to free up memory for orphan resources.
Thank you very much for your help! I have not worked with memory in this way before, I will test it.
Thanks for the hint that orphan resources are deleted when reloading the terminal! Many such things are not obvious to me yet.
p.s. everything in this example is perfect! There is something to look at, something to think about and an opportunity to experiment... The code is short.
You don't need to. In the Canvas destructor it is automatically executed:
~iCanvas() { Destroy(); ChartRedraw();};