thefrozencoder

Programming and Technology blog

High Vmmem CPU and or Memory usage Docker Desktop

Recently I noticed that the service vmmem had high memory usage at the same time I was not running any containers in Docker Desktop, the memory usage was actually around 96%, the CPU usage was higher than normal as well.  The key was to create a .wslconfig file (windows) in your %USERPROFILE% folder with the config options from the Microsoft Site. Below is what I am currently using.

[wsl2]
memory=6GB # limits VM memory in WSL to 6 GB only
processors=4 # limits the WSL2 to use 4 virtual processors only

Once you create the file and add the options you can restart the LX subsystem using the following Powershell command (must be at an elevated prompt)

Restart-Service LxssManager

You may get some errors in Docker Desktop about communication but you can just restart Docker Desktop to get rid of them.

Update to Narayana Vyas Kondreddi's generate insert script for SQL Server 2012

If you are like me you like re-using tools that you find extremely simple and easy to use. That is the case with Narayana Vyas Kondreddi’s sp_generate_inserts script for SQL Server 2000, 2005, (works with 2008 yet not documented). So when I installed SQL Server 2012 developer my first item was to re-create all of the system stored procs I have in my toolbox.

Unfortunately running the script from the above link will generate an error because the code references a system stored procedure that no longer exists in SQL Server 2012 master.dbo.sp_MS_upd_sysobj_category.  This stored procedure toggles the system mode feature where any object created while the mode is enabled is flagged as a system object.  Since the undocumented sproc does not exist the script will be created but it will not work properly.

However there is a small update that can be done to the original script to fix the issue.

You need to remove the following lines

--Turn system object marking on
EXEC master.dbo.sp_MS_upd_sysobj_category 1
GO

And replace the following lines

--Turn system object marking off
EXEC master.dbo.sp_MS_upd_sysobj_category 2
GO

With

EXEC sys.sp_MS_marksystemobject sp_generate_inserts
GO

The script should ruin without any errors and work as it did in the previous versions.

I have emailed the owner of the script so hopefully he will update the script for 2012.

Workaround for Installing KB Article KB971092 successfully

In some cases there is an issue with installing the following update “Security Update for Microsoft Visual Studio 2008 Service Pack 1 (KB971092)”.  The workaround to properly install the update you must set the security on the files vsvars32.bat and vcvarsall.bat to allow the local Users group write permission on those files.  I am not sure why this is an issue but from reading other posts and such on the issue most of the affected people do not have vc++ installed.

They can be found in the following folders:

x86

  • C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
  • C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat

x64

  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat

VS 2008 - Duplicate Toolbox Items

I opened up VS 2008 the other day and noticed that there were multiple instances of the same toolbox item listed (e.g. there were 4 Button controls listed).  I tried to reset the Toolbox but nothing seemed to solve the problem.

The fix was to close VS and delete the 4 *.tbd files located @ C:\Documents and Settings\USER_NAME\Local Settings\Application Data\Microsoft\VisualStudio\9.0\ (under XP / Win2k3) or C:\Users\USER_NAME\AppData\Local\Microsoft\VisualStudio\9.0\ (under Vista / Win2k8 / Win7)

Upon restarting VS seems to rebuild these files and fixed the issue.  Not sure why this happened and seems nobody else does either.

T4 Template lovin'

The following is a couple of T4 templates that I have been fooling around with in my spare time (sharing the time between jQuery, StringTemplate view engine for ASP.NET MVC and other endeavors).  For the most part these templates are nothing special, they generate both the T-SQL (stored procedures) and a simple but effective data access layer.  Like I said nothing special.

A good resource for starting with T4 templates is @ David Hayden site where he has a Screencast on how to use them.  Below describes some of the settings used to get my simple sample up and running.
Extract the _common.tt, DataClass.tt and T-SQL.tt files from the zip and add them to your VS project in a folder (like Generation).  In the _common.tt file there are some settings (variables) that you can use to modify how the code is generated.  You will need SQL 2005 client tools installed on your machine as it uses the SMO object library.  Once the code is compiled just cut and paste it into separate class files and run the T-SQL code on your db.

  • ConnectionString - This is your connection string to your database
  • TableName - This is the table you are going to run the code against
  • SchemaName - Use this for applying a schema to your T-SQL code if you use schemas (default is dbo)
  • ColumnsToOmit - Comma delimited list of columns to omit from the DAL code that is generated
  • NameSpace - Namespace of your application
  • ProcPrefix - Use to add a prefix to your stored procedures (ie. up_)
  • UseShortProperties - True | False to tell code generation to generate the C# short form for get/set properties
  • insertColumnsAsGetdate - Comma delimited list of column names that will automatically be assigned the GETDATE() T-SQL statement on an Insert.  (Also omits the fields from the insert statement parameters)
  • updateColumnsAsGetdate - Comma delimited list of column names that will automatically be assigned the GETDATE() T-SQL statement on an Update.  (Also omits the fields from the update statement parameters)

The code is supplied as is and if it's broken fix it, you're a programmer aren't you?  :P

T4 Templates.zip (4.98 kb)