Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


minimize usage memory of program


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2010, 11:36 PM
Byak@'s Avatar
Basic4ppc Veteran
 
Join Date: Jul 2008
Posts: 412
Send a message via ICQ to Byak@
Awards Showcase
Beta Tester 
Total Awards: 1
Default minimize usage memory of program

i'm read about .Net and memory and find interesting code
Code:
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AddHandler Application.Idle, AddressOf FlushMemory
    End Sub

    Private Sub FlushMemory()
        If System.Environment.OSVersion.Platform = PlatformID.Win32NT Then
            SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1)
        End If
    End Sub
    
    <DllImport("kernel32.dll")> _
    Public Shared Function SetProcessWorkingSetSize(ByVal handle As IntPtr, ByVal minimumWorkingSetSize As Integer, ByVal maximumWorkingSetSize As Integer) As Boolean
    End Function
this work on Desctop only and set a working set of program to min

how use it on b4ppc?
__________________
I'll Kill you, I'll Crash you, I'll never be yours!
--------------------------------------------------
Qtek s110; o2 XDA Flame; Nokia E63 red;
ASUS Eee PC 901 (Windows XP sp3) + TouchScreen;
Reply With Quote
  #2 (permalink)  
Old 02-03-2010, 02:03 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 3,893
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

The .NET Framework has good memory management code. I wouldn't bypass that by calling the native API. Let the Framework worry about looking after memory.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #3 (permalink)  
Old 02-03-2010, 03:19 PM
Byak@'s Avatar
Basic4ppc Veteran
 
Join Date: Jul 2008
Posts: 412
Send a message via ICQ to Byak@
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Andrew, as i know .Net allocate a "working set" in memory (when program start) and size of this set bigger than needed (for future) (and if we have many RAM this set bigger).
this code must change a working set to minimum needed.
for example our program have only one form and button,showed msgbox. but in memory this program use (!) 12mb in virtual memory (i have 2gb RAM) and it's working set 9mb!
as i'm understand with code,posted by me our program must use only ~1mb
__________________
I'll Kill you, I'll Crash you, I'll never be yours!
--------------------------------------------------
Qtek s110; o2 XDA Flame; Nokia E63 red;
ASUS Eee PC 901 (Windows XP sp3) + TouchScreen;
Reply With Quote
  #4 (permalink)  
Old 02-03-2010, 03:29 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 3,893
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Don't worry about it. The memory is allocated virtual memory, it does not mean that any actual physical RAM is mapped to it. If the OS does come under memory pressure then the Framework can surrender unused memory back to the OS. Just leave it to OS and the Framework to look after memory, that's what they are designed to do efficiently.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exceptions usage ghale Questions & Help Needed 6 07-29-2009 04:57 PM
Image usage with sqllite tremara1 Questions & Help Needed 9 07-10-2009 08:31 PM
Dim memory usage JamesC Questions & Help Needed 2 07-21-2008 08:09 AM
Way to decrease memory usage Andrew_572 Questions & Help Needed 3 01-04-2008 09:44 AM
Memory Usage Scubaticus Questions & Help Needed 6 07-03-2007 05:37 PM


All times are GMT. The time now is 09:48 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0