ADF(BC)--当使用绑定VO的<af:table>时可能会导致的内存问题

当在ADF应用中,使用<af:table>显示VO的数据时最常用的一种方式,但如果使用不当,会导致出现内存占用过高甚至泄露。

究竟什么情况下会发生呢?当我们的VO的数据量很大时,而我们仅仅使用了页面的分页或者使用滚动的方式时,如果我们一下直接跳转到最后一页(分页模式下),或是直接将滚动条拖到最底下时,ADF框架就会把数据集的所有数据都加载到内存中去,这时候就会出现占用很大的内存,甚至出现内存泄露导致服务器宕机。

我们来验证一下,为验证数据行的加载,专门在VO的行实现类里的构造方法打印以及话,如下图,下图是默认拖拽到页面的一个table,默认显示25行数据,下图可看到生产了25个视图行对象,也就是说加载了25行数据。

我们在页面把table的滚动条直接拖到最后,见下图,创建3376个视图行对象,事实上是把结果集的所有数据到加载(在table使用分页,即设置table的scrollPolicy="page"时直接点击最后一页也是一样):

解决这个问题,可以在VO层里设置使用分页模式,默认时AccessModel="Scrollable",改为Range Paging或Range Paging incremental即可。


还有关于使用Vo的分页也可以在AM里设置,如下图:

最后,关于VO在大数据量下使用<af:table>还有一些其他的问题,后面将继续分析。


可以使用Python中的pandas库来将XML数据转化为Excel格式,以下是示例代码: ```python import pandas as pd from xml.etree import ElementTree # 读取XML数据 xml_data = '''<?xml version="1.0" encoding="UTF-8"?> <list> <item> <userId>3f2bc360-adc1-4adf-bbd9-092939603af8</userId> <eid>xuyang</eid> <displayName>yang xu</displayName> <type>registered</type> </item> <item> <userId>5d7713fd-8133-40a8-94ad-3a145ed44df8</userId> <eid>yisirui</eid> <displayName>sirui yi</displayName> <type>registered</type> </item> <item> <userId>5dcaf2c0-fb7c-47fe-99bc-df21ede9011b</userId> <eid>xiaosun</eid> <displayName>xuyang sun</displayName> <type>registered</type> </item> <item> <userId>7ea060ff-d6e4-4552-9682-6483eb692a8f</userId> <eid>alex</eid> <displayName>alex Yu</displayName> <type>registered</type> </item> <item> <userId>e190e122-96ef-4b43-9b9e-11a08400c87f</userId> <eid>wanglinkai</eid> <displayName>cui xiai</displayName> <type>registered</type> </item> <item> <userId>e3d6d07e-7a34-47c0-969f-9401ddeab675</userId> <eid>cuikairui</eid> <displayName>kairui cui</displayName> <type>registered</type> </item> <item> <userId>f304a0e1-e0a9-4518-9099-4ef5c2cdb22f</userId> <eid>xuchenxi</eid> <displayName>chenxi xu</displayName> <type>registered</type> </item> </list>''' root = ElementTree.fromstring(xml_data) # 将XML数据转化为DataFrame data = [] for item in root.findall('item'): userId = item.find('userId').text eid = item.find('eid').text displayName = item.find('displayName').text type_ = item.find('type').text data.append([userId, eid, displayName, type_]) df = pd.DataFrame(data, columns=['userId', 'eid', 'displayName', 'type']) # 将DataFrame保存为Excel文件 df.to_excel('data.xlsx', index=False) ``` 运行该代码后,会在当前目录下生成一个名为"data.xlsx"的Excel文件,其中包含了XML数据中的各个字段。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值