Presentation Program eats up all memory

Discuss any general programming issues here
Post Reply
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Presentation Program eats up all memory

Post by fingus »

This interactive Presentation Programm is eating up all the memory, when saving and running as windows-executable and i dunno know why!

Code: Select all

@VERSION 5,0	  ; required Compilerversion
ExitOnError(False)

;@BRUSH 1000, "refresh.png", {LoadAlpha = True}

; Constants
Const #VERSION = "Lapstore Presenter V0.2"
Const #SPEED = 400

; Variables

p_loadsettings = {}

Function p_loadsettings:read()
; prüfen ob da
isda=Exists("config.ini")

; wenn da öffen
If isda = True
	OpenFile(1,"config.ini")
    b = ReadLine(1)
    h = ReadLine(1)
    CloseFile(1)
EndIf

; wenn nicht da, anlegen
If isda = False
    OpenFile(1,"config.ini",#MODE_WRITE)
    WriteLine(1,"1024")
    WriteLine(1,"768")
    CloseFile(1)
    angelegt=1
EndIf
EndFunction


p_loadsettings:read()
If angelegt=1 Then p_loadsettings:read()



; Programminfos
@APPTITLE #VERSION
@APPAUTHOR "Niels Schapke"
@APPVERSION "0.2"
@APPCOPYRIGHT "Scienide digital artwork"
@APPDESCRIPTION "Lapstore Window Presenter"

SetDisplayAttributes({title=#VERSION, width=1600, height=1200, Layers= True, scalemode=#SCALEMODE_LAYER, Smoothscale=True, scalewidth = b, scaleheight = h})
ChangeDisplayMode(#DISPMODE_FULLSCREEN, b, h )
HidePointer()
SetFontColor($FFFFFF)
SetFont(#SANS,30)
SetFontStyle(#ANTIALIAS)

; zuletzt geändert laden
data$ = downloadfile("http://lapstore.schapke.org/a.php")
vf$ = definevirtualfilefromstring(data$, "a.txt")
OpenFile(1,vf$)
alt$ = ReadLine(1)
CloseFile(1)
;DebugPrint(zg$)
undefinevirtualstringfile(vf$)
data$ = nil

; ip rausfinden
data$ = downloadfile("http://www.showmyip.com/index.php")
vf$ = definevirtualfilefromstring(data$, "ip.html")
OpenFile(1,vf$)
ip$ = ReadLine(1)
anfang = FindStr(ip$,"Connection ")
anfang = anfang + 11
ip$=UnrightStr(ip$,anfang)
ende = FindStr(ip$," -->")
ip2$=LeftStr(ip$,ende)
;Print(ip2$)
CloseFile(1)
undefinevirtualstringfile(vf$)
data$ = nil

; laderoutine
Print(#VERSION)
Print("\nProgrammiert 2012 von Niels Schapke\n")
Print("==========================\n")
Print("ESC oder linke Maustaste zum Beenden!\n\n")

Print("Prüfe Internetverbindung ...")
test = isonline()
If test = True Then Print("Online!\n")
If test = False
    Print("Offline!\n\nAchtung! Internetverbindung wird zwingend benötigt, damit der Presenter laufen kann!\n")
 	Wait(200)
    End
EndIf

Print("Eigene IP-Adresse: ",ip2$,"\n")
Print("Nehme voreingestellte Zielauflösung: ",b,"x",h," Pixel\n\n")

Function p_config()
; konfig vom server laden
If verbose="" Then Print("Lade Konfiguration vom Server ...")
data$ = downloadfile("http://lapstore.schapke.org/dat.txt")
vf$ = definevirtualfilefromstring(data$, "dat.txt")
OpenFile(1,vf$)
ip$ = ReadLine(1)
CloseFile(1)
;Print(ip$)
undefinevirtualstringfile(vf$)
data$ = nil
If verbose="" Then Print("ok\n\n")
; konfig separieren
c = {}
For i=0 To 12
c[i]=MidStr(ip$,i,1)
Next
;Print(c[6])
EndFunction

p_config()


If verbose="" Then Print("Lade Grafiken vom Server:\n")

a = {}
a = {"dat.txt","angebot1.jpg","angebot2.jpg","angebot3.jpg","angebot4.jpg","angebot5.jpg","angebot6.jpg","lapstore1.jpg","lapstore2.jpg","lapstore3.jpg","oeffnungszeiten.jpg","sonstige1.jpg","sonstige2.jpg"}
baseaddy$ = "http://lapstore.schapke.org/"

Function p_laden()

For i=1 To 12

If c[i-1]="1"
If verbose="" Then Print("Lade",a[i],"...")

addr$ = AddStr(baseaddy$,a[i])
data$ = downloadfile(addr$)
vf$ = definevirtualfilefromstring(data$, "image.jpg")
LoadBrush(i,vf$)
undefinevirtualstringfile(vf$)
data$ = nil
If verbose="" Then Print("ok\n")
EndIf

Next

EndFunction

p_laden()
If verbose="" Then Print("\nStarte Presentation!...")
Wait(50)
 

; hauptteil
Function p_mainloop()

; Uhr anzeigen
If c[12]="1"
DisplayBrushFX(8,0,0)
time$ = GetTime()
date$ = GetDate()
SetFont(#SANS,400)
SetFontStyle(#ANTIALIAS)  
CreateTextObject(1,time$)
SetFont(#SANS,200)
SetFontStyle(#ANTIALIAS)
CreateTextObject(2,date$)
DisplayTextObjectFX(1,#CENTER,#CENTER-400)
DisplayTextObjectFX(2,#CENTER,#CENTER+400)
Wait(#SPEED)
EndIf



If c[6]="1"
; Begrüßungs-Logo anzeigen
DisplayBrushFX(7,0,0)
Wait(#SPEED)
EndIf

; Angebot 1-6 anzeigen
For i=0 To 5
If c[i]="1"
DisplayBrushFX(i+1,0,0)
Wait(#SPEED)
EndIf
Next

If c[7]="1"
; Logo2 anzeigen
DisplayBrushFX(8,0,0)
Wait(#SPEED)
EndIf

If c[10]="1"
; Sonstiges1 anzeigen
DisplayBrushFX(11,0,0)
Wait(#SPEED)
EndIf

If c[11]="1"
; Sonstiges2 anzeigen
DisplayBrushFX(12,0,0)
Wait(#SPEED)
EndIf

If c[8]="1"
; Logo3 anzeigen
DisplayBrushFX(9,0,0)
Wait(#SPEED)
EndIf

If c[9]="1"
; Öffnungszeiten anzeigen
DisplayBrushFX(10,0,0)
Wait(#SPEED)
EndIf

; zuletzt geändert laden
data$ = downloadfile("http://lapstore.schapke.org/a.php")
vf$ = definevirtualfilefromstring(data$, "a.txt")
OpenFile(1,vf$)
neu$ = ReadLine(1)
CloseFile(1)
;DebugPrint(zg$)
undefinevirtualstringfile(vf$)
data$ = nil

If alt$ = neu$
    Else
alt$ = neu$
verbose="1"
p_config()
DisplayBrush(1000,0,0)
p_laden()
EndIf



EndFunction

SetInterval(1, p_mainloop, 1000/1)
LeftMouseQuit(TRUE)
EscapeQuit(True)
Repeat
    WaitEvent
Forever

User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Re: Presentation Program eats up all memory

Post by fingus »

You have to comment out the whole block between:

; zuletzt geändert laden

to

; laderoutine

to get it work
User avatar
Juan Carlos
Posts: 891
Joined: Mon Sep 06, 2010 1:02 pm

Re: Presentation Program eats up all memory

Post by Juan Carlos »

I tested it under my netbook and almost I want buy one laptop, fantastic to donwload the pictures from Internet and your own server.
User avatar
fingus
Posts: 269
Joined: Fri Sep 16, 2011 9:53 am

Re: Presentation Program eats up all memory

Post by fingus »

I found the bug:

I forget to undo all brushes after every effect was shown, this cause the x86 execute to grow bigger and bigger in ram!
User avatar
Juan Carlos
Posts: 891
Joined: Mon Sep 06, 2010 1:02 pm

Re: Presentation Program eats up all memory

Post by Juan Carlos »

fingus wrote:I found the bug:

I forget to undo all brushes after every effect was shown, this cause the x86 execute to grow bigger and bigger in ram!
I didn't find that problem I tested with Hollwyood enviroment and Internet, without problems.
Post Reply