BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Media storage space"
, by thechange
Determining the total amount of memory available for media by creating an excessive amount of images.
Code
; This is a technique without the use of an external DLL so it could be ; considered as 'brute force' image creation within Blitz. ; ; Know that Blitz will use, respectively: ; 1) Video memory ; 2) System memory ; 3) Windows swapfile ; ; Using a DLL to retrieve information such as total available memory by ; interfacing directly with Windows is highly recommended. Const SX = 1280 Const SY = 1024 Type Image Field Image End Type Global Images Graphics SX , SY , 0 , 2 Global SZ = GraphicsDepth() SetBuffer BackBuffer() Global ImageSize = 0 Local ImageNumber = 0 Repeat Cls ; See how big one image really is (in video memory) ImageNumber = ImageNumber + 1 If ImageNumber = 1 NoImages = AvailVidMem() Else If ImageNumber = 2 ImageSize = NoImages - AvailVidMem() End If ; Try create another image If Not Create() Then OutOfMemory ; Inform user Locate 0 , 0 Print "Images: " + Images Print "Free: " + AvailVidMem() Print "Used: " + ( TotalVidMem() - AvailVidMem() ) Print "Size (1 image): " + ImageSize Print "Size (all images): " + (ImageSize * Images) Flip Until KeyHit(1) End Function Create() Image.Image = New Image Image\Image = CreateImage(SX,SY) If Image\Image Then Images = Images + 1 Return Image\Image > 0 End Function Function OutOfMemory() Text1$ = "Out of memory after:" + Chr(13) Text2$ = Images + " images of " + SX + "x" + SY + "x" + SZ + Chr(13) Text3$ = "Video memory used: " + (TotalVidMem() - AvailVidMem()) + Chr(13) Text4$ = "Video memory free: " + AvailVidMem() + Chr(13) Text5$ = "Size of 1 image: " + ImageSize + Chr(13) Text6$ = "Total allocated: " + (ImageSize * Images) + Chr(13) RuntimeError Text1 + Text2 + Text3 + Text4 + Text5 + Text6 End Function ;-->
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations