Wast of memory

Everything else that doesn't fall into one of the other PB categories.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Wast of memory

Post by GPI »

I wrote a little calender-Tool (display a week, show the day in the systray and popup on a specific time).

Only one big problem: A small 75KB-Tool with not many things need about 2.5-3.8 MB!

http://caosandkin.bei.t-online.de/pureb ... lender.zip

Sorry, complete german an it is not really compileable with IDE (IDE should take cut.termin.pb). The programm need the termin.res as resource.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

btw:

Code: Select all

If OpenWindow(1,0,0,200,200,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Test")
  If CreateGadgetList(WindowID())
    
    Repeat
      Event=WaitWindowEvent()
      
    Until Event=#PB_Event_CloseWindow
  EndIf
EndIf
need over 2 MB RAM.
Kris_a
User
User
Posts: 92
Joined: Sun Feb 15, 2004 8:04 pm
Location: Manchester, UK

Post by Kris_a »

I don't think that's the source of the problem. This code alone uses nearly 3mb:

Code: Select all

repeat
forever
Maybe that's a collection of PB's pre-allocated buffers? strings, etc?
DominiqueB
Enthusiast
Enthusiast
Posts: 103
Joined: Fri Apr 25, 2003 4:00 pm
Location: France

Hello GPI

Post by DominiqueB »

Where could one get the .tes needed, and the ResFreeIcon() and others functions to be able to compile your code ?

Thank's for sharing.

Dominique
Dominique

Windows 10 64bits. Pure basic 32bits
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

the Res-file is called ("Icons.Res") sorry for the wrong name.

in "Cut.Termine.PB" you found all procedures, you need (it is the cutted-Version of termine.pb)
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

GPI,

That's a nice program!

I noticed a couple of English mistakes, if you're interested:

Calendar not Calender
Tuesday should be abbreviated "Tu", not "Th"
Sunday should be abbreviated "Su", not "So"
September, not Septembers
October, not Octobers
November is OK!
December, not Decembers

Regards,
Eric
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Thanks, I will correct it tomorrow.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

@GPI

I agree with you, even the most simple program in Purebasic uses at least 2Mb of RAM...

Bug or feature ? :wink:
freak
PureBasic Team
PureBasic Team
Posts: 5947
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Kris_a wrote:I don't think that's the source of the problem. This code alone uses nearly 3mb:

Code: Select all

repeat
forever
Maybe that's a collection of PB's pre-allocated buffers? strings, etc?
What are you talking about??
572 Kb memory usage, nothing more.

(1.4 mb with debugger)
quidquid Latine dictum sit altum videtur
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

freak wrote:What are you talking about??
572 Kb memory usage, nothing more.
(1.4 mb with debugger)
Ok, create a window with a gadget...

Minimize it a few times (memory should drop a lot ~200Kb average), then bring it up again and memory usage will about 1/3 of what it consumed when it first started, and after a bit of usage back to a few MB... 8O

I've made several applications in Purebasic, and here's the memory consuption of each (just opened and doing nothing)
  • o Pesquisa CTT
    (1 window, 3 gadgets, 1 database - 73Kb EXE)
    First Run - 3.6Mb
    After minimizing and restoring - 528Kb

    o Husse Gest
    (1 Window, 30 gadgets, 3 databases - 23Kb EXE)
    First Run - 2.8Mb
    After minimizing and restoring - 725Kb

    o Rendas 2003
    (1 Window,83 gadgets, 1 database - 36Kb EXE)
    First Run - 3.6Mb
    After minimizing and restoring - 432Kb

    o IPGest (Just GUI, no code yet!!!)
    (1 Window, 15 gadgets - 15Kb EXE)
    First Run - 2.4Mb
    After minimizing and restoring - 760Kb
BTW: Winamp skinned and playing an MP3 takes 1.7Mb of memory :?
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Just linking the kernel32, gui32 and user32 dll takes about 2 Mb of ram. On my XP computer, notepad takes 2.8 mb, just after the launch...
Here WinAmp 5.01 (take 21 Mb of ram, nothing playing). So I guess it's correct, it's more a 'windows' feature.
StarHawk
User
User
Posts: 55
Joined: Sun Nov 02, 2003 7:27 am

Take SoftIce

Post by StarHawk »

Take SoftICE and open up the operating system and take a look at what's happening on Windows XP. The gdi32.dll, kernel32.dll, user32.dll, advapi32.dll, ntdll.dll, ole32.dll, shell32.dll, etc.. are copied into a protected "sandbox" of memory to be granted permission to be used, unlike Windows 98 where the same dlls the operating system uses are the same dlls any program running in memory uses. This makes the operating system virtually "crash proof", and protects software by essentially breaking programs like SoftIce.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Windows libraries are all shared between all programs, and are loaded when needed by the first program.

This should means that the first program on your computer will see memory go up by a lot as windows loads everything. However, the subsequent programs will share these resources and there won't be a problem.

So, what happens when you load something else first, then your PB executable? Is it following this pattern?
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post by Seldon »

GedB: are you sure ? That is not good old AmigaOS (waiting for 4.0) :) . Windows DLLs aren't shared by default, it means each program that opens a DLL will have ITS OWN instance of that DLL. That can be good and bad (not good for memory). Actually it's also possible to write shared DLLs, but I am not sure system DLLs like kernel32,user32, etc... are shared.
Post Reply