Wednesday, April 1, 2015

'Memory gates checking failed because the free memory WCF' FIX: InsufficientMemoryException

You're getting ready to run your WCF service application and you see this error: "Memory gates checking failed because the free memory" populate in your browser.

Memory gates checking failed because the free memory (9338880 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.


This exception is simply caused by insufficient memory allocated to the WCF service at the current moment, thus, the application throws an "InsufficientMemoryException." Thankfully, the exception is descriptive enough to provide additional information on solving the issue.

Stack Trace Exception:
[InsufficientMemoryException: Memory gates checking failed because the free memory (9338880 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.]

FIX:

In your web.config look under configuration / system.serviceModel / serviceHostingEnvironment element. Add a minFreeMemoryPercentageToActivateService attribute and set it to zero (0). 

 <configuration>  
  <system.serviceModel>  
   <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />  
  </system.serviceModel>  
 </configuration>  

PS: If the serviceHostingEnvironment already exist, simply append/add the "minFreeMemoryPercentageToActivateService" attribute and set it to zero (0). 

Join the discussion on StackOverflow

Wednesday, December 12, 2012

Day and Night Effect Using jQuery

Day and night effect on any html page can easily mean switching between two different stylesheets to enhance user experience. This tutorial will demonstrate how to switch between two stylesheets efficiently using jQuery.

End Result:



THINGS YOU MIGHT NEED:
jQuery basic knowledge
HTML file 
External CSS files

Saturday, November 24, 2012

Getting the window title in AS3

In AS3, you can easily access the name of the HTML page that the .swf is embedded in. To do this, you can use ExternalInterface. First, import the ExternalInterface library.

import flash.external.ExternalInterface;

Next, call the window location from JavaScript using the call function of ExternalInterface.

flash.external.ExternalInterface.call("window.location.href.toString");

This should work for most browsers; however, there have been reported problems using this method. If you experience difficulties with your browser, try wrapping the call in a JavaScript function.

flash.external.ExternalInterface.call("function(){ return window.location.href.toString();}")

In addition, you may want to find the path of the .swf file. Using the following code will get the path of the .swf:

var swfLocation = this.location.href;

One final note, the ExternalInterface calls only work when JavaScript is enabled on the page, so if it does not work, this may be the issue.

Happy Coding,
kieblera5

Thursday, November 8, 2012

How to Center a Page in CSS

Conflicting margins can be frustrating and confusing when constructing a stylesheet for your website. However, centering your website is a common practice to avoid margin conflicts. Centering your website also helps with readability and works pretty well with dynamic display of content.

The following tutorials will show you how to center your website using an ID selector in CSS.

THINGS YOU MIGHT NEED:
CSS basic knowledge
HTML file 
External CSS file

HTML File:

<body>
  <div id="page-wrap">
  all websites HTML here 
  </div>
</body>
External CSS File:

#page-wrap {     width: 800px;
     margin: 0 auto;
}
In other to avoid margin conflicts when resizing your window, it is very important to set the width of the selector to a giving pixel ( e.g 800px ) and also set the margin's initial value to 0 and auto to horizontally center the page.

Monday, March 1, 2010

Dictionary Shortener

Recently, I had to write a program that shortened the dictionary. What I mean by this is that using a full dictionary (over 237,000 words), I needed to weed out the words that were longer than eight letters and shorter than three letters. I needed a list of letters between three and eight letters for an upcoming game that happens to need a dictionary to check against.

Why do I bring this up? Well, my program takes advantage of fstream, a coder's good friend or enemy, depending on your understanding of it.

In my next posting, I will show you the finer points of using fstream, but for now, here is the code for the dictionary shortening program:



#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
 
int main()
{
    string word;
    ifstream infile;
    ofstream outfile;
    int count=0;
    infile.open("fulldictionary.txt");
    if(infile.fail())
    {
        cout<<"File could not be opened\n";
        system("PAUSE");
        return 0;
    }
    outfile.open("dictionary_short.txt");
    if(outfile.fail())
    {
        cout<<"File could not be opened\n";
        system("PAUSE");
        return 0;
    }
    for(int i=0;!infile.fail();i++)
    {
        getline(infile,word);
        if(word.length()>=3&&word.length()<=8)
        {
            count+=1;
            cout<<count<<": "<<word<<endl;
            outfile<<word<<endl;
        }
    }
    infile.close();
    outfile.close();
    cout<<"There were "<<count<<" words saved in dictionary_short.txt\n";
    system("PAUSE");
    return 0;
}



The above code assumes that you have a file called "fulldictionary.txt" in the project folder and will automatically create the output file. There's no need to make that one.

Friday, February 26, 2010

Creating Road In Unity Game Engine

Unity game engine is a great engine for developing game on PC, MAC, iPhone, and other platforms. However, I noticed that Unity does not have a road editor compared to Torque (game engine). One can use primitives to resolve this issue, but I prefer to use a 3d modeling tool. Thus, in this tutorial I will show you how to create roads using 3ds Max.

THINGS YOU MIGHT NEED:
a) A 3D modeling tool
b) Road Design/Map
c) Road Textures

1) Open 3ds Max, click CREATE and select SHAPES.
(click the picture to view in X-Large)

1b) Enter/Select all the necessary values and settings as desired. (Use the same values and setting to achieve similar results as this tutorial)


2) Create the desired road using the top view.


3) Select the Map Editor. (Shortcut: hit M on the keyboard to pop up the Map Editor)

 

3b) Click on the none button next to Diffuse. Double Click on Bitmap and select your road texture.

 

 4)  Make sure the desired material is selected.
4a) Select the "Assign Material to Selection" button in the Material editor to assign material
4b) Select the "Show Standard map in Viewport" to show material layout in your Viewport.
4c) Play Around with the Tiling Values to get the desired tiling.


5) Export as .FBX to Unity Game Engine.



~* By: Verse316 *~

Tuesday, January 5, 2010

Simple Console Program & Code Snippet Embeding.

Happy New Year! There will lots of code altering and editing on this blog this year. Thus, displaying code in code snippets will be very effective. How do you display or embed code snippets on your blog? There are several ways you can embed scripts or code on your blog. One of the easiest ways is to use Microsoft Live Writer. Once you have that installed you may need a plug-in that helps with formatting and highlighting.

Here is an example with a simple Console Program I made:
   1: #include <iostream>

   2: #include <iomanip>

   3: #include <string>

   4:  

   5: using namespace std;

   6:  

   7: int main()

   8: {

   9:     //** Declarations **    

  10:     double hourpay, twoweeks, month, year;

  11:     int ans, weeksWorked;

  12:     string name;

  13:     bool flag = false; 

  14:  

  15:     cout << "Welcome to the Budget Console" << endl;

  16:     cout << endl;

  17:     cout << "Please enter your name: ";

  18:     getline(cin, name);

  19:     system("cls");

  20:  

  21:     cout << name << ", How much do you earn per hour: ";

  22:     cin >> hourpay;

  23:     cout << endl;

  24:     cout << "How much do you work in a week: ";

  25:     cin >> weeksWorked;

  26:     cout << endl;

  27:     system("cls");

  28:  

  29:     //** Menu **

  30:     while (!flag)

  31:     {

  32:     cout << "\t Menu" << endl;

  33:     cout << "1) Calculate how much I earn in 2 weeks."<< endl;

  34:     cout << "2) Calculate how much I earn in a month."<< endl;

  35:     cout << "3) Calculate how much I earn in a year: ";

  36:     cin >> ans;

  37:     cout << endl;

  38:  

  39:     //** Calculation **

  40:      twoweeks = hourpay * weeksWorked;

  41:      month = twoweeks * 2;

  42:      year = (twoweeks * 2) * 12;

  43:  

  44:     //** Outputs **

  45:     if (ans == 1) {         

  46:           cout << "Your Two Weeks Pay: $" << twoweeks << ".00 " << endl;

  47:           flag = true;

  48:     }

  49:     else if (ans == 2) {        

  50:         cout << "Your a month Pay: $" << month << ".00 " << endl;

  51:         flag = true;

  52:     }

  53:     else if (ans == 3) {        

  54:         cout << "Your a month Pay: $" << year << ".00 " << endl;

  55:         flag = true;

  56:     }

  57:     else {

  58:       cout << "Invalid Selection" << endl;

  59:     }

  60:       }

  61:     system("pause");

  62:     return 0;

  63: }