Forum > Graphics

Out of heap

(1/1)

BubikolRamios:
This is repeated x times until '0ut of heap' , I suspect "PaintBox1.canvas.Draw" line. Should be anything freed in process ?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var   image: TBGRABitmap;begin       image := TBGRABitmap.Create(BitmapCopyFromForm1);               //... change of image ...           PaintBox1.canvas.Draw(0,0,image.Bitmap);          image.Free;        end;                   
BitmapCopyFromForm1: Tbitmap; is created on form create and changed occasionally.
But for this post, think of it as not changed at all.

jamie:
I don't know that component that well, but my guess is you need to have local B:TBitmap that you can assign from the IMAGE.Bitmap;

use the local and then free the local before exiting the block.

Martin_fr:
Your example has a lot of code missing. A lot of code that could "leak" (loose that memory)


Compile your app with "heaptrc" (-gh) => project options > Compiler settings > Debugging
Also make sure to include debug info (dwarf), and "display line numbers..." -gl

And make sure you also change the options of the bgra package to include debug info (dwarf).

Then run your app (on windows enable console). Check the console output of your app when it exists => most likely it will print stacktraces where memory was leaked. (allocated but never freed).

Lots of then entries will be nested, if your loose a bitmap then you loose all the stuff inside it too. So you need to search for the one in your code.

You can copy that output and paste it into => menu: view > leaks and traces

Thaddy:
Out of heap means also basically out of memory, so for sure you need to free a lot.
I have never seen an out of heap error in 40 odd years, so concrats! you must be one of the first...and doing something very,very wrong, but we do not know what because your info is too scarse.
The heap size itself is usually available physical memory + the available swap space.
(this is not the case for embedded, where the heap can be explicitly defined, depending on system)

BubikolRamios:
moved to: https://forum.lazarus.freepascal.org/index.php/topic,69850.0.html

if nothing there, will go into Martin_fr advice (-:

Navigation

[0] Message Index

Go to full version