+ Start a Discussion
Nicolás KacowiczNicolás Kacowicz 

Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 243.564KB

Hi, I posted the same question on Apex Code Development but maybe it fits better here.

Hello, I'm getting both of these errors.
I'm trying to upload Accounts through a CSV file from a Visualforce Page. The csv file is 300kb.
I have a for that reads the csv file, and then I use Database.upsert.

I got both the Apex Class and the VF Page from http://www.forcetree.com/2010/08/read-and-insert-records-from-csv-file.html.

I just customized to my needs, mostly the Apex Class. 
This is the Visualforce Page:

<apex:page sidebar="false" controller="FileUploaderAccountTotal" showHeader="false">
    <apex:form >
        <apex:sectionHeader title="Upload data from CSV file"/>
        <apex:pagemessages />
        <apex:pageBlock >
            <!--  Component to allow user to upload file from local machine -->
                <apex:inputFile value="{!contentFile}" filename="{!nameFile}" /> <apex:commandButton action="{!ReadFile}" value="Upload File" id="theButton" style="width:70px;"/>
            <!-- After the user clicks the 'Upload File' button, this section displays the inserted data -->
            <apex:pageblocktable value="{!uploadedAccountsTotal}" var="con" rendered="{!NOT(ISNULL(uploadedAccountsTotal))}">
                <apex:column headerValue="Name">
                    <apex:outputField value="{!con.Name}"/>
                <apex:column headerValue="Sponsor">
                    <apex:outputField value="{!con.Sponsor__c}"/>
                <apex:column headerValue="Areas">
                    <apex:outputField value="{!con.Areas__c}"/>

I even tried to put public transient Blob contentFile{get;set;} with the transient but it didn't matter. I need to be able to upload a file larger than that.

For the CPU time I don't understand what I'm doing wrong, I have this big for with no query inside and then after an upload I have a for of the same size that inserts some Lookup IDs needed to the Object.