473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

memory question... I don't think I posted twice, if so sorry....

When would it be appropriate to call this: Anytime, specifuc events? When is
smart when is not... Also, can someone give me a complete example of doing
this in vb.net? Please define the hprocess and IntPtr proc and int min and
int max.... Say my app runs in an instance named appnew, what would be the
call?

Thanks in advance.....

Anthony Nystrom
Basically, you want to call the Win32 api function
SetProcessWorkingSetSize(hProcess, -1, -1).
If you're not familiar with P/Invoke, here's some code....

[DllImport("kernel32.dll")]
public static extern bool SetProcessWorkingSetSize( IntPtr proc, int min,
int max );
...
...
public static void ReclaimMemory()
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle, -1, -1 );
}

Nov 20 '05 #1
2 935

"Anthony Nystrom" <an******@genetibase.com> wrote in message
news:e3**************@TK2MSFTNGP10.phx.gbl...
When would it be appropriate to call this: Anytime, specifuc events? When is smart when is not... Also, can someone give me a complete example of doing
this in vb.net? Please define the hprocess and IntPtr proc and int min and int max.... Say my app runs in an instance named appnew, what would be the
call?

Thanks in advance.....

Anthony Nystrom

Hi
I can't answer your questions, but here's a conversion of the code in your
post.:
imports System.Runtime.InteropServices
....

<DllImport("kernel32.dll")> _
Public Shared Function SetProcessWorkingSetSize(ByVal proc As IntPtr, ByVal
min As Integer, ByVal max As Integer) As Boolean

End Function

Public Sub ReclaimMemory()

System.GC.Collect()

System.GC.WaitForPendingFinalizers()

SetProcessWorkingSetSize(Process.GetCurrentProcess ().Handle, -1, -1)

End Sub

Regards,

Jens Andersen
Nov 20 '05 #2
* "Anthony Nystrom" <an******@genetibase.com> scripsit:
[...]

See my reply in the other instance of your post...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Rabbit63 | last post by:
Hi: I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript): 1.The first way is: <% var sql = "select firstname from...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
30
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g =...
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
0
by: Kevin Bartz | last post by:
-----Original Message----- From: Kevin Bartz Sent: Monday, August 09, 2004 10:37 AM To: 'mike@thegodshalls.com' Subject: RE: Out of swap space & memory Thanks for your reply, Mike!...
2
by: Mike | last post by:
Hi, I am new to C and having problems with the following program. Basically I am trying to read some files, loading data structures into memory for latter searching. I am trying to use structres...
15
by: tom | last post by:
why delete the dynamically allocated memory twice causes an error, see the code below: int _tmain(int argc, _TCHAR* argv) { int *pi = new int(12); cout<<*pi; delete pi; delete pi; }
5
by: Dan Dorey | last post by:
I've implemented the ICloneable interface on a class of mine. I've implemented it in two different ways both of which I feel should work correctly, but only one does and I'd be curious to know why....
0
by: George2 | last post by:
Hello everyone, Sorry that this question is related to another question I posted some time before because I have some new findings and self-analysis. My question is why sometimes from perfmon...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.