Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mär 28, 2024 22:39

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: Memory leak....
BeitragVerfasst: Fr Mai 28, 2010 21:47 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
I Start a project very simple.
I use the dglOpenGL.pas for the main tamplete and the textures.pas.

The program makes this simple thing.

I have a cube in the middle of the screen.
I use the virtual keys (with the form.keydown ) up and down.
Up changes the image from a folder.
The folder has at least 10.000 images.
But is small near 100 kb.
The images is in png format.

My problem is when i change the image the memory doesn't freed.
The texture some how stays inside the memory.
So in sort time (the program stats with 19MB) i have 400 mb.

Can someone tell me how can i solve this...

here is the fuctinon to lad a png texture.
Code:
function LoadPNGTexture(Filename: String; var Texture : GLuint; LoadFromResource : Boolean) : Boolean;
var
  //pData : Pointer;
  PNGImage : TPNGGraphic;
  BMP : TBitmap;
  Data : Array of LongWord;
  W, Width : Integer;
  H, Height : Integer;
  Line : ^LongWord;
  C : LongWord;
begin
  PNGImage := TPNGGraphic.Create;
  try
      PNGimage.LoadFromFile(Filename);
    except
      MessageBox(0, PChar('Couldn''t load PNG - "'+ Filename +'"'), PChar('BMP Unit'), MB_OK);
      Exit;
    end;
  BMP := TBitmap.Create;
  BMP.pixelformat:=pf32bit;
  BMP.width:= PNGImage.Width;
  BMP.height:= PNGImage.Height;
  BMP.canvas.draw(0,0,PNGImage);

  Width :=BMP.Width;
  Height :=BMP.Height;
  SetLength(Data, Width*Height);
  For H:=0 to Height-1 do
  Begin
    Line :=BMP.scanline[Height-H-1];   // flip JPEG
    For W:=0 to Width-1 do
    Begin
      c:=Line^ and $FFFFFF; // Need to do a color swap
      Data[W+(H*Width)] :=(((c and $FF) shl 16)+(c shr 16)+(c and $FF00)) or $FF000000;  // 4 channel.
      inc(line);
    End;
  End;

  BMP.Free;
  PNGImage.Free;

  Texture:=CreateTexture(Width, Height, GL_RGBA, addr(Data[0]));
  Result:= true;
end;



and here is the call from keydown

Code:
if Key = VK_UP then
    begin
      if WherePointer <=0 then
        WherePointer := 1;
      if FileExists('pic'+WherePointer+'.png') then
        LoadTexture('pic'+WherePointer+'.png'',texCube,False)
      else
        LoadTexture(nopicture.png',TexCube,False)
      WherePointer := WherePointer - 1;
    end;
;

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Memory leak....
BeitragVerfasst: Fr Mai 28, 2010 22:03 
Offline
DGL Member
Benutzeravatar

Registriert: Do Sep 02, 2004 19:42
Beiträge: 4158
Programmiersprache: FreePascal, C++
Do you call glDeleteTextures at some place, specifically before assigning a new texture to TexCube?

greetings

_________________
If you find any deadlinks, please send me a notification – Wenn du tote Links findest, sende mir eine Benachrichtigung.
current projects: ManiacLab; aioxmpp
zombofant networkmy photostream
„Writing code is like writing poetry“ - source unknown


„Give a man a fish, and you feed him for a day. Teach a man to fish and you feed him for a lifetime. “ ~ A Chinese Proverb


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: Memory leak....
BeitragVerfasst: Fr Mai 28, 2010 22:30 
Offline
DGL Member
Benutzeravatar

Registriert: Fr Mai 28, 2010 13:28
Beiträge: 25
Wohnort: Ελλάδα -- Greece
Programmiersprache: Delphi, FreePascal
Lord Horazont hat geschrieben:
Do you call glDeleteTextures at some place, specifically before assigning a new texture to TexCube?

greetings


Thank you my friend i solve this problem...
I use the glDeleteTextures before i call the LoadTexture and the problem solves thank you very very much ....

Thanks...

_________________
Try to think first before you act....


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 10 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.102s | 17 Queries | GZIP : On ]