当前位置: 代码迷 >> J2SE >> 急啊,怎么解决JAVA HEAP SPACE错误
  详细解决方案

急啊,怎么解决JAVA HEAP SPACE错误

热度:57   发布时间:2016-04-24 13:07:06.0
急啊,如何解决JAVA HEAP SPACE错误?
Java code
    public static void searchForChains(Synset source,Synset target,ArrayList<ChainNode> inherit)    {        if(inherit.size() < max+1)        {            try            {                ArrayList<ChainNode> temp = (ArrayList<ChainNode>)inherit.clone();                PointerTargetNodeList list = PointerUtils.getInstance().getDirectHypernyms(source);                if(0 != list.size())                {                    searchForChain(list,target,temp,1);                }                list =    PointerUtils.getInstance().getDirectHyponyms(source);                if(0 != list.size())                {                    searchForChain(list,target,temp,2);                }                list =    PointerUtils.getInstance().getHolonyms(source);                if(0 != list.size())                {                    searchForChain(list,target,temp,3);                }                list =    PointerUtils.getInstance().getMeronyms(source);                if(0 != list.size())                {                    searchForChain(list,target,temp,4);                }                inherit = null;                list = null;            }            catch(JWNLException e)            {                e.printStackTrace();            }        }        else        {            inherit = null;            return;        }    }    public static void searchForChain(PointerTargetNodeList list,Synset target,ArrayList<ChainNode> inherit,int type)    {        for(Iterator it = list.iterator();it.hasNext();)        {            PointerTargetNode Node = (PointerTargetNode)it.next();            if(!target.equals(Node.getSynset()))            {                if(!Circle.hasCircle(inherit,Node.getSynset()))                {                    ArrayList<ChainNode> temp = (ArrayList<ChainNode>)inherit.clone();                    switch(type)                    {                        case 1:                            temp.add(new ChainNode(Node.getSynset(),new StringBuffer("hypernym")));                            break;                        case 2:                            temp.add(new ChainNode(Node.getSynset(),new StringBuffer("hyponym")));                            break;                        case 3:                            temp.add(new ChainNode(Node.getSynset(),new StringBuffer("holonym")));                            break;                        case 4:                            temp.add(new ChainNode(Node.getSynset(),new StringBuffer("meronym")));                            break;                        default:                            break;                    }                    searchForChains(Node.getSynset(),target,temp);                    Node = null;                    temp = null;                }                else                {                    inherit = null;                    return;                }            }            else            {                switch(type)                {                    case 1:                        inherit.add(new ChainNode(Node.getSynset(),new StringBuffer("hypernym")));                        break;                    case 2:                        inherit.add(new ChainNode(Node.getSynset(),new StringBuffer("hyponym")));                        break;                    case 3:                        inherit.add(new ChainNode(Node.getSynset(),new StringBuffer("holonym")));                        break;                    case 4:                        inherit.add(new ChainNode(Node.getSynset(),new StringBuffer("meronym")));                        break;                    default:                        break;                }                Chains.add(inherit);                return;            }        }    }
  相关解决方案